Skip to content

Commit

Permalink
fix merge-tsv
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen committed Nov 9, 2023
1 parent a258c72 commit a1a003c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
13 changes: 11 additions & 2 deletions clinica/iotools/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,24 @@ def merge_tsv(

check_bids_folder(bids_directory)

atlas_selection = []
if volume_atlas_selection is not None:
atlas_selection += volume_atlas_selection
if freesurfer_atlas_selection is not None:
atlas_selection += freesurfer_atlas_selection
if group_selection == ():
group_selection = None
if pet_tracers_selection == ():
pet_tracers_selection = None

create_merge_file(
bids_directory,
output_tsv,
caps_dir=caps_directory,
pipelines=pipelines,
ignore_scan_files=ignore_scan_files,
ignore_sessions_files=ignore_session_scan_files,
volume_atlas_selection=volume_atlas_selection,
freesurfer_atlas_selection=freesurfer_atlas_selection,
atlas_selection=atlas_selection,
pvc_restriction=pvc_restriction,
tsv_file=subjects_sessions_tsv,
group_selection=group_selection,
Expand Down
7 changes: 4 additions & 3 deletions clinica/iotools/utils/pipeline_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _get_atlas_name(atlas_path: Path, pipeline: str) -> str:
else:
raise ValueError(f"Not supported pipeline {pipeline}.")
try:
atlas_name = atlas_path.stem.split(splitter)[1].split("_")[0]
atlas_name = atlas_path.stem.split(splitter)[-1].split("_")[0]
except Exception:
raise ValueError(
f"Unable to infer the atlas name from {atlas_path} for pipeline {pipeline}."
Expand Down Expand Up @@ -179,6 +179,7 @@ def _extract_metrics_from_pipeline(
"""
from clinica.utils.stream import cprint

caps_dir = Path(caps_dir)
if df.index.names != ["participant_id", "session_id"]:
try:
df.set_index(
Expand All @@ -189,15 +190,15 @@ def _extract_metrics_from_pipeline(

if group_selection is None:
try:
group_selection = os.listdir(caps_dir / "groups")
group_selection = [f.name for f in (caps_dir / "groups").iterdir()]
except FileNotFoundError:
return df, None
else:
group_selection = [f"group-{group}" for group in group_selection]
ignore_groups = group_selection == [""]

subjects_dir = Path(caps_dir) / "subjects"
pipeline_df = pd.DataFrame()
subjects_dir = caps_dir / "subjects"
for participant_id, session_id in df.index.values:
ses_path = subjects_dir / participant_id / session_id
mod_path = _get_mod_path(ses_path, pipeline)
Expand Down

0 comments on commit a1a003c

Please sign in to comment.