TractSeg icon indicating copy to clipboard operation
TractSeg copied to clipboard

Apply TractSeg to the study specific population template using the peaks of the spherical harmonic function at each voxel as input

Open Nassim3235 opened this issue 2 years ago • 9 comments

Hi, I want to apply TractSeg to the study specific population template using the peaks of the spherical harmonic function at each voxel as input. I have peaks.nii.gz after running this command: sh2peaks wmfod_template_MNI.mif peaks.nii.gz But, when I try to run the following command, I get the following error:

TractSeg -i peaks.nii.gz -o template/tract_segmentation/ --output_type tract_segmentation

Error: Loading weights from: /home/gha/.tractseg/pretrained_weights_tract_segmentation_v3.npz Downloading pretrained weights (~140MB) ... Traceback (most recent call last): File "/home/gha/miniconda3/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn conn = connection.create_connection( File "/home/gha/miniconda3/lib/python3.9/site-packages/urllib3/util/connection.py", line 95, in create_connection raise err . . . . . raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='zenodo.org', port=443): Max retries exceeded with url: /record/3518348/files/best_weights_ep220.npz?download=1 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f7750f9c8b0>: Failed to establish a new connection: [Errno 111] Connection refused'))

Thanks in advance for your help

Nassim3235 avatar Apr 08 '23 09:04 Nassim3235

The code is having problems downloading the model weights from zenodo. Sometimes zenodo is having download issues. I would suggest to try it again another time and/or from another internet network.

wasserth avatar Apr 08 '23 11:04 wasserth

Thanks a lot! I fixed the problem. The following commands runned correctly: TractSeg -i peaks.nii.gz -o template/tract_segmentation/ --output_type tract_segmentation TractSeg -i peaks.nii.gz -o template/endings_segmentation/ --output_type endings_segmentation

But, when I try to run "TractSeg -i peaks.nii.gz -o template/TOM/ --output_type TOM" , There is no file in TOM folder and I get the following error:

Error:

Loading weights from: /home/gha/.tractseg/pretrained_weights_peak_regression_part1_v2.npz 100%|█████████████████████████████████████████| 144/144 [00:22<00:00, 6.44it/s] joblib.externals.loky.process_executor._RemoteTraceback: """ Traceback (most recent call last): File "/home/gha/miniconda3/lib/python3.9/site-packages/nibabel/loadsave.py", line 42, in load stat_result = os.stat(filename) FileNotFoundError: [Errno 2] No such file or directory: 'template/TOM/bundle_segmentations/AF_left.nii.gz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/gha/miniconda3/lib/python3.9/site-packages/joblib/externals/loky/process_executor.py", line 428, in _process_worker r = call_item() File "/home/gha/miniconda3/lib/python3.9/site-packages/joblib/externals/loky/process_executor.py", line 275, in call return self.fn(*self.args, **self.kwargs) . . . . FileNotFoundError: No such file or no access: 'template/TOM/bundle_segmentations/AF_left.nii.gz'

Nassim3235 avatar Apr 10 '23 07:04 Nassim3235

Is this the complete error message? There seems to be missing something.

wasserth avatar Apr 14 '23 06:04 wasserth

This is the complete error message:

TractSeg -i peaks.nii.gz -o template/TOM/ --output_type TOM

Loading weights from: /home/gha/.tractseg/pretrained_weights_peak_regression_part1_v2.npz Downloading pretrained weights (~140MB) ... downloaded in 913.93s 100%|████████████████████████████████████████| 144/144 [00:23<00:00, 6.24it/s] joblib.externals.loky.process_executor._RemoteTraceback: """ Traceback (most recent call last): File "/home/gha/miniconda3/lib/python3.9/site-packages/nibabel/loadsave.py", line 42, in load stat_result = os.stat(filename) FileNotFoundError: [Errno 2] No such file or directory: 'template/TOM/bundle_segmentations/AF_left.nii.gz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/gha/miniconda3/lib/python3.9/site-packages/joblib/externals/loky/process_executor.py", line 428, in _process_worker r = call_item() File "/home/gha/miniconda3/lib/python3.9/site-packages/joblib/externals/loky/process_executor.py", line 275, in call return self.fn(*self.args, **self.kwargs) File "/home/gha/miniconda3/lib/python3.9/site-packages/joblib/_parallel_backends.py", line 620, in call return self.func(*args, **kwargs) File "/home/gha/miniconda3/lib/python3.9/site-packages/joblib/parallel.py", line 288, in call return [func(*args, **kwargs) File "/home/gha/miniconda3/lib/python3.9/site-packages/joblib/parallel.py", line 288, in return [func(*args, **kwargs) File "/home/gha/miniconda3/lib/python3.9/site-packages/tractseg/libs/peak_utils.py", line 263, in _process_bundle img = nib.load(join(tract_seg_path, bundle + ".nii.gz")) File "/home/gha/miniconda3/lib/python3.9/site-packages/nibabel/loadsave.py", line 44, in load raise FileNotFoundError(f"No such file or no access: '{filename}'") FileNotFoundError: No such file or no access: 'template/TOM/bundle_segmentations/AF_left.nii.gz' """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/gha/miniconda3/bin/TractSeg", line 420, in main() File "/home/gha/miniconda3/bin/TractSeg", line 325, in main seg = run_tractseg(data, args.output_type, File "/home/gha/miniconda3/lib/python3.9/site-packages/tractseg/python_api.py", line 240, in run_tractseg seg = peak_utils.mask_and_normalize_peaks(seg, tract_segmentations_path, File "/home/gha/miniconda3/lib/python3.9/site-packages/tractseg/libs/peak_utils.py", line 271, in mask_and_normalize_peaks results_peaks = Parallel(n_jobs=nr_cpus)(delayed(_process_bundle)(idx, bundle) File "/home/gha/miniconda3/lib/python3.9/site-packages/joblib/parallel.py", line 1098, in call self.retrieve() File "/home/gha/miniconda3/lib/python3.9/site-packages/joblib/parallel.py", line 975, in retrieve self._output.extend(job.get(timeout=self.timeout)) File "/home/gha/miniconda3/lib/python3.9/site-packages/joblib/_parallel_backends.py", line 567, in wrap_future_result return future.result(timeout=timeout) File "/home/gha/miniconda3/lib/python3.9/concurrent/futures/_base.py", line 445, in result return self.__get_result() File "/home/gha/miniconda3/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result raise self._exception FileNotFoundError: No such file or no access: 'template/TOM/bundle_segmentations/AF_left.nii.gz'

Nassim3235 avatar Apr 16 '23 09:04 Nassim3235

For the previous commands (output type tract_segmentation and endings_segmentations) you have to specify the same output folder. And for output_type TOM as well. The correct subfolders are automatically generated. Just do it the same way as it is stated in the documentation.

wasserth avatar Apr 16 '23 17:04 wasserth

Problem solved. Thank you very much for your help.

Nassim3235 avatar Apr 17 '23 08:04 Nassim3235

Hi, I met the same problem as yours, could you please tell me how did you solve the Failed to establish a new connection: [Errno 111] Connection refused'))? Just changed the internet network?

yutinghe99 avatar Jun 20 '23 04:06 yutinghe99

Hi, Yes, we just changed the internet network.

Nassim3235 avatar Jun 20 '23 05:06 Nassim3235

Thanks! I solved the problem. I also try to apply TractSeg to the study specific population template. I've done whole brain fixel-based analysis according to the MRtrix3 document. And I got some significant FC, FD, FDC fixels between 3 of my groups. Now I would like to label those tracts which have significant fixels. I followed this scripts https://osf.io/9ch6a, ran the following commands sh2peaks wmfod_template_MNI.mif peaks.nii.gz TractSeg -i peaks.nii.gz -o tractseg/ --output_type tract_segmentation TractSeg -i peaks.nii.gz -o tractseg/ --output_type endings_segmentation TractSeg -i peaks.nii.gz -o tractseg/ --output_type TOM Tracking -i peaks.nii.gz -o tractseg/ --tracking_format tck --nr_fibers 10000

The given scripts is an Tract-of-interest analysis, I"d to do whole brain analysis, and I want to know what's the next step according to my goal?

Seems you are also doing the FBA, I would appreciate it if you could give me some guidance.

Yuting

yutinghe99 avatar Jun 26 '23 14:06 yutinghe99