Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow skipping normalization when compute_cell_density #70

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion atlas_densities/app/cell_densities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion atlas_densities/densities/cell_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Loading