diff --git a/src/australianimagingservice/mri/human/neuro/t1w/preprocess.py b/src/australianimagingservice/mri/human/neuro/t1w/preprocess.py index 971da16..688c507 100644 --- a/src/australianimagingservice/mri/human/neuro/t1w/preprocess.py +++ b/src/australianimagingservice/mri/human/neuro/t1w/preprocess.py @@ -1019,55 +1019,6 @@ def join_task_catalogue( ), ] ) - - wf.add( - FunctionTask( - collate_parcs, - name="collate_parcs", - input_spec=SpecInfo( - name="CollateParcsInputs", - bases=(BaseSpec,), - fields=[(p, Mif) for p in parcellation_list], - ), - output_spec=SpecInfo( - name="CollateParcsOutputs", - bases=(BaseSpec,), - fields=[("out_dir", DirectoryOf[Mif])], # type: ignore[misc] - ), - out_dir="out_dir", - ) - ) - - for parcellation in parcellation_list: - - wf.add( - single_parc( - t1w=wf.lzin.t1w, - parcellation=parcellation, - freesurfer_home=freesurfer_home, - mrtrix_lut_dir=mrtrix_lut_dir, - cache_dir=cache_dir, - fs_license=fs_license, - fastsurfer_executable=fastsurfer_executable, - fastsurfer_python=fastsurfer_python, - name=parcellation, - ) - ) - - setattr( - wf.collate_parcs.inputs, - parcellation, - getattr(wf, parcellation).lzout.parc_image, - ) - - wf.set_output(("parcellations", wf.collate_parcs.lzout.out_dir)) - wf.set_output(("vis_image_fsl", wf.desikan.lzout.vis_image_fsl)) - wf.set_output(("ftt_image_fsl", wf.desikan.lzout.ftt_image_fsl)) - wf.set_output(("vis_image_freesurfer", wf.desikan.lzout.vis_image_freesurfer)) - wf.set_output(("ftt_image_freesurfer", wf.desikan.lzout.ftt_image_freesurfer)) - wf.set_output(("vis_image_hsvs", wf.desikan.lzout.vis_image_hsvs)) - wf.set_output(("ftt_image_hsvs", wf.desikan.lzout.ftt_image_hsvs)) - return wf @@ -1118,11 +1069,59 @@ def all_parcs( } wf = Workflow( - name="t1_processing_pipeline", + name=name, input_spec=input_spec, cache_dir=cache_dir, ) + wf.add( + FunctionTask( + collate_parcs, + name="collate_parcs", + input_spec=SpecInfo( + name="CollateParcsInputs", + bases=(BaseSpec,), + fields=[(p, Mif) for p in parcellation_list], + ), + output_spec=SpecInfo( + name="CollateParcsOutputs", + bases=(BaseSpec,), + fields=[("out_dir", DirectoryOf[Mif])], # type: ignore[misc] + ), + out_dir="out_dir", + ) + ) + + for parcellation in parcellation_list: + + wf.add( + single_parc( + t1w=wf.lzin.t1w, + parcellation=parcellation, + freesurfer_home=freesurfer_home, + mrtrix_lut_dir=mrtrix_lut_dir, + cache_dir=cache_dir, + fs_license=fs_license, + fastsurfer_executable=fastsurfer_executable, + fastsurfer_python=fastsurfer_python, + name=parcellation, + ) + ) + + setattr( + wf.collate_parcs.inputs, + parcellation, + getattr(wf, parcellation).lzout.parc_image, + ) + + wf.set_output(("parcellations", wf.collate_parcs.lzout.out_dir)) + wf.set_output(("vis_image_fsl", wf.desikan.lzout.vis_image_fsl)) + wf.set_output(("ftt_image_fsl", wf.desikan.lzout.ftt_image_fsl)) + wf.set_output(("vis_image_freesurfer", wf.desikan.lzout.vis_image_freesurfer)) + wf.set_output(("ftt_image_freesurfer", wf.desikan.lzout.ftt_image_freesurfer)) + wf.set_output(("vis_image_hsvs", wf.desikan.lzout.vis_image_hsvs)) + wf.set_output(("ftt_image_hsvs", wf.desikan.lzout.ftt_image_hsvs)) + return wf @@ -1142,3 +1141,27 @@ def collate_parcs(out_dir: Path = None, **parcs: "Mif") -> "DirectoryOf[Mif]": wf = all_parcs(*args) # type: ignore[arg-type] wf(t1w=sys.argv[1]) +# if __name__ == "__main__": +# import sys + +# # Expecting the first argument to be the T1-weighted image path +# t1w_path = sys.argv[1] + +# # Provide sensible default values or pass from command-line arguments +# # freesurfer_home = "/Applications/freesurfer/" # Adjust this path as per your setup +# # mrtrix_lut_dir = "/Users/arkievdsouza/mrtrix3/share/mrtrix3/labelconvert/" # Adjust this path as per your setup +# # cache_dir = "/Users/arkievdsouza/git/t1-pipeline/working-dir/" # Temporary directory for cache +# # fs_license = ( +# # "/Applications/freesurfer/license.txt " # Path to the FreeSurfer license file +# # ) + +# # Pass the arguments explicitly +# wf = all_parcs(*sys.argv[1]) +# # freesurfer_home=freesurfer_home, +# # mrtrix_lut_dir=mrtrix_lut_dir, +# # cache_dir=cache_dir, +# # fs_license=fs_license, +# # ) # type: ignore[arg-type] + +# # # Run the workflow with the T1-weighted image as input +# wf(t1w=t1w_path)