Skip to content

Commit

Permalink
Fix PlotPathDistanceFits for mtypes with no fit
Browse files Browse the repository at this point in the history
Change-Id: I04ed788ecdf4e10e510bf5ff26df329319a8340c
  • Loading branch information
adrien-berchet committed Nov 26, 2020
1 parent 0a368c0 commit 5341bae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/synthesis_workflow/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ def _process_scaling_rule(
if mtype != "default"
]

L.debug("Number of files: %s", [(t, len(f)) for t, f in file_lists])

# Fit data and update TMD parameters
for mtype, slope, intercept in Parallel(nb_jobs)(
delayed(_fit_population)(mtype, file_names) for mtype, file_names in file_lists
Expand Down
19 changes: 16 additions & 3 deletions src/synthesis_workflow/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,18 @@ def _get_fit_population(
):
"""Get projections and path lengths of a given and a synthetic population."""
# Load biological neurons
return_error = (mtype, None, None, None, None, None, None)
if len(files) > 0:
input_population = load_population(files)
else:
return (mtype, None, None)
return return_error + (f"No file to load for mtype='{mtype}'",)
if (
tmd_parameters.get("context_constraints", {})
.get("apical", {})
.get("extent_to_target")
is None
):
return return_error + (f"No fit for mtype='{mtype}'",)

# Get X and Y from biological population
x = get_path_distances(input_population)
Expand All @@ -648,7 +656,7 @@ def _get_fit_population(
# Get X and Y from synthetic population
x_synth = get_path_distances(synthetic_population)

return mtype, x, y, x_clean, y_clean, x_synth, y_synth
return mtype, x, y, x_clean, y_clean, x_synth, y_synth, None


def plot_path_distance_fits(
Expand Down Expand Up @@ -692,9 +700,11 @@ def plot_path_distance_fits(
for mtype in mtypes
]

L.debug("Number of files: %s", [(t, len(f)) for t, f in file_lists])

ensure_dir(output_path)
with PdfPages(output_path) as pdf:
for mtype, x, y, x_clean, y_clean, x_synth, y_synth in Parallel(nb_jobs)(
for mtype, x, y, x_clean, y_clean, x_synth, y_synth, msg in Parallel(nb_jobs)(
delayed(_get_fit_population)(
mtype,
files,
Expand All @@ -704,6 +714,9 @@ def plot_path_distance_fits(
)
for mtype, files in file_lists
):
if all([i is None for i in [x, y, x_clean, y_clean, x_synth, y_synth]]):
L.warning(msg)
continue
fig = plt.figure()

# Plot points
Expand Down

0 comments on commit 5341bae

Please sign in to comment.