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

Leaf region will only trigger if the region exists #48

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,29 @@ def _check_variables_consistency(
if np.isfinite(deltas.loc[region_name, cell_type]):
for desc_id in id_set:
if np.isnan(x_result.loc[desc_id, cell_type]):
raise AtlasDensitiesError(
f"Cell count estimate of region named '{region_name}' for cell type "
f"{cell_type} was given for certain whereas the cell count of "
f"descendant id {desc_id} is not certain."
)
if ((deltas.loc[region_name, cell_type] in [0.0, np.inf]) &
cveraszto marked this conversation as resolved.
Show resolved Hide resolved
(x_result.loc[id_, cell_type] == 0.0) or
(np.isnan(x_result.loc[id_, cell_type]))):
'''
cveraszto marked this conversation as resolved.
Show resolved Hide resolved
If the region's cell count value was set to 0 because the region does
not exist we don't have to raise an error. Instead of x_result
volumes.loc[id_, 'volume'] == 0.0 would be a better condition.. '''
deltas.loc[region_name, cell_type] = np.inf
x_result.loc[id_, cell_type] = np.nan
warnings.warn(
f"Cell count estimate of region named "
f"'{region_name}' for cell type {cell_type} was given 0 for "
f"its volume is 0 whereas the cell count of descendant id {desc_id} "
f"is not certain. Cell count estimate for this region is thus set "
cveraszto marked this conversation as resolved.
Show resolved Hide resolved
f"to np.nan to avoid inconsistency.",
AtlasDensitiesWarning,
)

else:
raise AtlasDensitiesError(
f"Cell count estimate of region named '{region_name}' for cell type "
f"{cell_type} was given for certain whereas the cell count of "
)
lecriste marked this conversation as resolved.
Show resolved Hide resolved
neuron_count = neuron_counts.loc[id_, "cell_count"]
if (
not np.isnan(x_result.loc[id_, cell_type])
Expand Down
Loading