Skip to content

Commit

Permalink
A None value for mtypes means that all mtypes are taken
Browse files Browse the repository at this point in the history
Change-Id: I4f5fd144fff77b3fc699a4e7d78c875f1701226e
  • Loading branch information
adrien-berchet committed Nov 10, 2020
1 parent 7fc1c4d commit 8c92176
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 43 deletions.
1 change: 0 additions & 1 deletion examples/luigi_cfg/luigi_vacuum.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ morphology_path = repaired_morphology_path_h5
vacuum_synth_morphology_path = out_vacuum/vacuum_synth_morphologies
vacuum_synth_morphs_df_path = out_vacuum/vacuum_synth_morphs_df.csv
n_cells = 10
mtypes = ["all"]

# validation plots
[ValidateVacuumSynthesis]
Expand Down
10 changes: 1 addition & 9 deletions src/synthesis_workflow/tasks/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,12 @@ def requires(self):

def run(self):
""""""
mtypes = self.mtypes
if (
# pylint: disable=unsupported-membership-test
mtypes is None
or "all" in mtypes
):
mtypes = None

planes = load_planes_centerline(self.input()["atlas_planes"].path)["planes"]

_slicer = partial(
circuit_slicer,
n_cells=self.n_cells,
mtypes=mtypes,
mtypes=self.mtypes,
planes=planes,
hemisphere=self.hemisphere,
)
Expand Down
6 changes: 5 additions & 1 deletion src/synthesis_workflow/tasks/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ class SynthesisConfig(luigi.Config):
description="The list of cortical thicknesses",
)
mtypes = luigi.ListParameter(
default=None, description="The list of mtypes to process"
default=None,
description=(
"The list of mtypes to process (default is None, which means that all found "
"mtypes are taken)"
),
)


Expand Down
2 changes: 1 addition & 1 deletion src/synthesis_workflow/tasks/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def requires(self):
def run(self):
""""""
morphs_df = pd.read_csv(self.input()["morphologies"].path)
mtypes = morphs_df.mtype.unique()
mtypes = sorted(morphs_df.mtype.unique())
neurite_types = get_neurite_types(morphs_df, mtypes)

if self.input_tmd_parameters_path is not None:
Expand Down
6 changes: 1 addition & 5 deletions src/synthesis_workflow/tasks/vacuum_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ def run(self):
tmd_parameters = json.load(self.input()["tmd_parameters"].open())
tmd_distributions = json.load(self.input()["tmd_distributions"].open())

if (
# pylint: disable=unsubscriptable-object
self.mtypes is None
or self.mtypes[0] == "all"
):
if self.mtypes is None:
mtypes = list(tmd_parameters.keys())
else:
mtypes = self.mtypes
Expand Down
29 changes: 10 additions & 19 deletions src/synthesis_workflow/tasks/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,11 @@ def requires(self):

def run(self):
""""""
if (
# pylint: disable=unsubscriptable-object
self.mtypes is None
or self.mtypes[0] == "all"
):
mtypes = pd.read_csv(self.input().path).mtype.unique()
if self.mtypes is None:
mtypes = sorted(pd.read_csv(self.input().path).mtype.unique())
else:
mtypes = self.mtypes

for mtype in mtypes:
yield PlotSingleCollage(
collage_base_path=self.collage_base_path,
Expand Down Expand Up @@ -336,11 +333,8 @@ def requires(self):
def run(self):
""""""
morphs_df = pd.read_csv(self.input().path)
if (
self.mtypes is None
or self.mtypes[0] == "all" # pylint: disable=unsubscriptable-object
):
mtypes = morphs_df.mtype.unique()
if self.mtypes is None:
mtypes = sorted(morphs_df.mtype.unique())
else:
mtypes = self.mtypes

Expand Down Expand Up @@ -474,14 +468,11 @@ def run(self):
ref_morphs_df = pd.read_csv(self.input()["ref"].path)
test_morphs_df = pd.read_csv(self.input()["test"].path)

if self.mtypes is None or "all" in self.mtypes:
mtypes = None
else:
mtypes = self.mtypes

if mtypes is not None:
ref_morphs_df = ref_morphs_df.loc[ref_morphs_df["mtype"].isin(mtypes)]
test_morphs_df = test_morphs_df.loc[test_morphs_df["mtype"].isin(mtypes)]
if self.mtypes is not None:
ref_morphs_df = ref_morphs_df.loc[ref_morphs_df["mtype"].isin(self.mtypes)]
test_morphs_df = test_morphs_df.loc[
test_morphs_df["mtype"].isin(self.mtypes)
]

if self.config_path is not None:
with open(self.config_path) as f:
Expand Down
8 changes: 5 additions & 3 deletions src/synthesis_workflow/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ def plot_path_distance_fits(
# Read morphology DataFrame
morphs_df = pd.read_csv(morphs_df_path)

if mtypes is None or mtypes[0] == "all":
if mtypes is None:
mtypes = sorted(
[
mtype
Expand Down Expand Up @@ -837,14 +837,16 @@ def plot_scale_statistics(mtypes, scale_data, output_dir="scales", dpi=100):
plt.close(fig)

if mtypes is None:
mtypes = scale_data["mtype"].unique().tolist()
mtypes = sorted(scale_data["mtype"].unique())

for col in scale_data.drop(
columns=["worker_task_id", "mtype", "x", "y", "z"], errors="ignore"
).columns:
fig = plt.figure(figsize=(10, 20))
ax = plt.gca()
scale_data[["mtype", col]].boxplot(by="mtype", vert=False, ax=ax)
scale_data.loc[scale_data["mtype"].isin(mtypes), ["mtype", col]].boxplot(
by="mtype", vert=False, ax=ax
)

ax.grid(True)
fig.suptitle("")
Expand Down
3 changes: 0 additions & 3 deletions tests/data/in_small_O1/luigi.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ neurite_types = ["basal", "apical"]
trunk_max_tries = 100
s_samples = 5

[SynthesisConfig]
mtypes = ["all"]

[CircuitConfig]
circuit_somata_path = circuit_somata.mvd3
atlas_path = <path_to_atlas_directory>
Expand Down
1 change: 0 additions & 1 deletion tests/data/in_vacuum/luigi.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ morphology_path = repaired_morphology_path
# synthesize in vacuum
[VacuumSynthesize]
n_cells = 10
mtypes = ["all"]

####################################
# ########## Validation ########## #
Expand Down

0 comments on commit 8c92176

Please sign in to comment.