diff --git a/atlas_densities/app/cell_densities.py b/atlas_densities/app/cell_densities.py index f60a87b..bc809a2 100644 --- a/atlas_densities/app/cell_densities.py +++ b/atlas_densities/app/cell_densities.py @@ -183,8 +183,22 @@ def app(verbose): help="Path to density groups ids config", show_default=True, ) +@click.option( + "--skip-normalization", + is_flag=True, + default=False, + help="Whether to skip normalization of the Nissl path", + show_default=True, +) @log_args(L) -def cell_density(annotation_path, hierarchy_path, nissl_path, output_path, group_ids_config_path): +def cell_density( + annotation_path, + hierarchy_path, + nissl_path, + output_path, + group_ids_config_path, + skip_normalization, +): """Compute and save the overall mouse brain cell density. The input Nissl stain volume of AIBS is turned into an actual density field complying with @@ -219,6 +233,7 @@ def cell_density(annotation_path, hierarchy_path, nissl_path, output_path, group _get_voxel_volume_in_mm3(annotation), nissl.raw, group_ids_config=group_ids_config, + skip_normalization=skip_normalization, ) nissl.with_data(overall_cell_density).save_nrrd(output_path) diff --git a/atlas_densities/densities/cell_density.py b/atlas_densities/densities/cell_density.py index 7c806f4..f143a8c 100644 --- a/atlas_densities/densities/cell_density.py +++ b/atlas_densities/densities/cell_density.py @@ -60,6 +60,7 @@ def compute_cell_density( voxel_volume: float, nissl: FloatArray, group_ids_config: dict, + skip_normalization: bool = False, ) -> FloatArray: """ Compute the overall cell density based on Nissl staining and cell counts from literature. @@ -87,6 +88,8 @@ def compute_cell_density( voxel_volume: the common volume of a voxel associated to any of the input arrays. nissl: float array of shape (W, H, D) with non-negative entries. The input Nissl stain intensity. + group_ids_config: Layout described in `atlas_densities/app/data/metadata/README.txt` + skip_normalization: whether the normalization should be skipped Returns: float array of shape (W, H, D) with non-negative entries. The returned array is a @@ -97,7 +100,8 @@ def compute_cell_density( """ nissl = np.asarray(nissl, dtype=np.float64) - nissl = utils.normalize_intensity(nissl, annotation, threshold_scale_factor=1.0, copy=False) + if not skip_normalization: + nissl = utils.normalize_intensity(nissl, annotation, threshold_scale_factor=1.0, copy=False) nissl = utils.compensate_cell_overlap(nissl, annotation, gaussian_filter_stdv=-1.0, copy=False) group_ids = utils.get_group_ids(region_map, config=group_ids_config)