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

Update to match neurodatascience/nipoppy:main #101

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions nipoppy_cli/nipoppy/workflows/bids_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,13 @@ def run_single(self, participant_id: str, session_id: str):
)

return invocation_and_descriptor

def run_cleanup(self, **kwargs):
"""
Clean up after main BIDS conversion part is run.

Specifically:
- Write updated doughnut file
"""
self.save_tabular_file(self.doughnut, self.layout.fpath_doughnut)
return super().run_cleanup(**kwargs)
10 changes: 10 additions & 0 deletions nipoppy_cli/nipoppy/workflows/dicom_reorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,13 @@ def run_main(self):
"Error reorganizing DICOM files for participant "
f"{participant_id} session {session_id}: {exception}"
)

def run_cleanup(self):
"""
Clean up after main DICOM reorg part is run.

Specifically:
- Write updated doughnut file
"""
self.save_tabular_file(self.doughnut, self.layout.fpath_doughnut)
return super().run_cleanup()
33 changes: 33 additions & 0 deletions nipoppy_cli/tests/test_workflow_bids_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,39 @@ def test_setup(config: Config, tmp_path: Path):
assert not workflow.dpath_pipeline.exists()


@pytest.mark.parametrize(
"doughnut",
[
Doughnut(),
Doughnut(
data={
Doughnut.col_participant_id: ["01"],
Doughnut.col_visit_id: ["1"],
Doughnut.col_session_id: ["1"],
Doughnut.col_datatype: "['anat']",
Doughnut.col_participant_dicom_dir: ["01"],
Doughnut.col_in_raw_imaging: [True],
Doughnut.col_in_sourcedata: [True],
Doughnut.col_in_bids: [True],
}
).validate(),
],
)
def test_cleanup(doughnut: Doughnut, tmp_path: Path):
workflow = BidsConversionRunner(
dpath_root=tmp_path / "my_dataset",
pipeline_name="",
pipeline_version="",
pipeline_step="",
)
workflow.doughnut = doughnut

workflow.run_cleanup()

assert workflow.layout.fpath_doughnut.exists()
assert Doughnut.load(workflow.layout.fpath_doughnut).equals(doughnut)


@pytest.mark.parametrize(
"doughnut_data,participant_id,session_id,expected",
[
Expand Down
29 changes: 29 additions & 0 deletions nipoppy_cli/tests/test_workflow_dicom_reorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest

from nipoppy.tabular.dicom_dir_map import DicomDirMap
from nipoppy.tabular.doughnut import Doughnut
from nipoppy.tabular.manifest import Manifest
from nipoppy.utils import participant_id_to_bids_participant, session_id_to_bids_session
from nipoppy.workflows.dicom_reorg import DicomReorgWorkflow, is_derived_dicom
Expand Down Expand Up @@ -430,3 +431,31 @@ def test_run_main(

else:
assert not dpath_to_check.exists()


@pytest.mark.parametrize(
"doughnut",
[
Doughnut(),
Doughnut(
data={
Doughnut.col_participant_id: ["01"],
Doughnut.col_visit_id: ["1"],
Doughnut.col_session_id: ["1"],
Doughnut.col_datatype: "['anat']",
Doughnut.col_participant_dicom_dir: ["01"],
Doughnut.col_in_raw_imaging: [True],
Doughnut.col_in_sourcedata: [True],
Doughnut.col_in_bids: [True],
}
).validate(),
],
)
def test_cleanup(doughnut: Doughnut, tmp_path: Path):
workflow = DicomReorgWorkflow(dpath_root=tmp_path / "my_dataset")
workflow.doughnut = doughnut

workflow.run_cleanup()

assert workflow.layout.fpath_doughnut.exists()
assert Doughnut.load(workflow.layout.fpath_doughnut).equals(doughnut)
Loading