|
1 | | -# Copyright (C) 2022-2024 C-PAC Developers |
| 1 | +# Copyright (C) 2022-2025 C-PAC Developers |
2 | 2 |
|
3 | 3 | # This file is part of C-PAC. |
4 | 4 |
|
@@ -143,31 +143,12 @@ def gather_nifti_globs(pipeline_output_folder, resource_list, pull_func=False): |
143 | 143 | import glob |
144 | 144 | import os |
145 | 145 |
|
146 | | - import pandas as pd |
147 | | - import pkg_resources as p |
| 146 | + from CPAC.utils.outputs import group_derivatives |
148 | 147 |
|
149 | 148 | exts = ".nii" |
150 | 149 | nifti_globs = [] |
151 | 150 |
|
152 | | - keys_tsv = p.resource_filename("CPAC", "resources/cpac_outputs.tsv") |
153 | | - try: |
154 | | - keys = pd.read_csv(keys_tsv, delimiter="\t") |
155 | | - except Exception as e: |
156 | | - err = ( |
157 | | - "\n[!] Could not access or read the cpac_outputs.tsv " |
158 | | - f"resource file:\n{keys_tsv}\n\nError details {e}\n" |
159 | | - ) |
160 | | - raise Exception(err) |
161 | | - |
162 | | - derivative_list = list(keys[keys["Sub-Directory"] == "func"]["Resource"]) |
163 | | - derivative_list = derivative_list + list( |
164 | | - keys[keys["Sub-Directory"] == "anat"]["Resource"] |
165 | | - ) |
166 | | - |
167 | | - if pull_func: |
168 | | - derivative_list = derivative_list + list( |
169 | | - keys[keys["Space"] == "functional"]["Resource"] |
170 | | - ) |
| 151 | + derivative_list = group_derivatives(pull_func) |
171 | 152 |
|
172 | 153 | if len(resource_list) == 0: |
173 | 154 | err = "\n\n[!] No derivatives selected!\n\n" |
@@ -361,33 +342,14 @@ def create_output_dict_list( |
361 | 342 | """Create a dictionary of output filepaths and their associated information.""" |
362 | 343 | import os |
363 | 344 |
|
364 | | - import pandas as pd |
365 | | - import pkg_resources as p |
366 | | - |
367 | 345 | if len(resource_list) == 0: |
368 | 346 | err = "\n\n[!] No derivatives selected!\n\n" |
369 | 347 | raise Exception(err) |
370 | 348 |
|
371 | 349 | if derivatives is None: |
372 | | - keys_tsv = p.resource_filename("CPAC", "resources/cpac_outputs.tsv") |
373 | | - try: |
374 | | - keys = pd.read_csv(keys_tsv, delimiter="\t") |
375 | | - except Exception as e: |
376 | | - err = ( |
377 | | - "\n[!] Could not access or read the cpac_outputs.csv " |
378 | | - f"resource file:\n{keys_tsv}\n\nError details {e}\n" |
379 | | - ) |
380 | | - raise Exception(err) |
| 350 | + from CPAC.utils.outputs import group_derivatives |
381 | 351 |
|
382 | | - derivatives = list(keys[keys["Sub-Directory"] == "func"]["Resource"]) |
383 | | - derivatives = derivatives + list( |
384 | | - keys[keys["Sub-Directory"] == "anat"]["Resource"] |
385 | | - ) |
386 | | - |
387 | | - if pull_func: |
388 | | - derivatives = derivatives + list( |
389 | | - keys[keys["Space"] == "functional"]["Resource"] |
390 | | - ) |
| 352 | + derivatives = group_derivatives(pull_func) |
391 | 353 |
|
392 | 354 | # remove any extra /'s |
393 | 355 | pipeline_output_folder = pipeline_output_folder.rstrip("/") |
@@ -752,18 +714,10 @@ def prep_feat_inputs(group_config_file: str) -> dict: |
752 | 714 | import os |
753 | 715 |
|
754 | 716 | import pandas as pd |
755 | | - import pkg_resources as p |
756 | 717 |
|
757 | | - keys_tsv = p.resource_filename("CPAC", "resources/cpac_outputs.tsv") |
758 | | - try: |
759 | | - keys = pd.read_csv(keys_tsv, delimiter="\t") |
760 | | - except Exception as e: |
761 | | - err = ( |
762 | | - "\n[!] Could not access or read the cpac_outputs.tsv " |
763 | | - f"resource file:\n{keys_tsv}\n\nError details {e}\n" |
764 | | - ) |
765 | | - raise Exception(err) |
| 718 | + from CPAC.utils.outputs import Outputs |
766 | 719 |
|
| 720 | + keys = Outputs.reference |
767 | 721 | derivatives = list( |
768 | 722 | keys[keys["Derivative"] == "yes"][keys["Space"] == "template"][ |
769 | 723 | keys["Values"] == "z-score" |
|
0 commit comments