Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen committed Jul 22, 2024
1 parent 784c5e6 commit 863e3ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions clinica/iotools/utils/pipeline_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,17 @@ def _extract_metrics_from_pipeline(
pvc_restriction,
tracers_selection,
)
pipeline_df = pd.DataFrame.from_records(
records, index=["participant_id", "session_id"]
)
if records:
pipeline_df = pd.DataFrame.from_records(
records, index=["participant_id", "session_id"]
)
else:
pipeline_df = pd.DataFrame.from_records(
records, columns=["participant_id", "session_id"]
)
pipeline_df.set_index(
["participant_id", "session_id"], inplace=True, verify_integrity=True
)
summary_df = _generate_summary(
pipeline_df, pipeline, ignore_groups=group_selection == [""]
)
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/iotools/utils/test_data_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def test_add_data_to_merge_file_from_caps_empty_pipeline(tmp_path):
],
}
)

(tmp_path / "groups").mkdir()
with pytest.raises(
FileNotFoundError,
match=(
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/iotools/utils/test_pipeline_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,14 @@ def test_extract_metrics_from_pipeline_errors(tmp_path):
def test_extract_metrics_from_pipeline(tmp_path):
from clinica.iotools.utils.pipeline_handling import _extract_metrics_from_pipeline

(tmp_path / "groups").mkdir()
df = pd.DataFrame([["bar", "bar"]], columns=["participant_id", "session_id"])
assert _extract_metrics_from_pipeline(
tmp_path, df, ["metrics"], PipelineNameForMetricExtraction.T1_VOLUME
) == (
df,
None,
)
(tmp_path / "groups").mkdir()
(tmp_path / "groups" / "UnitTest").mkdir()
x, y = _extract_metrics_from_pipeline(
tmp_path, df, ["metrics"], PipelineNameForMetricExtraction.T1_VOLUME
Expand Down

0 comments on commit 863e3ad

Please sign in to comment.