RuntimeError: unexpected EOF, expected 31322553 more bytes. The file might be corrupted
Hi Prof, I am getting an error when I use Tractseg(version2.9) to treat non-HCP data and I am not sure what it is due to, any suggestions are well appreciated! Thank you!
The code for Tract Orientation Maps that I am running is: TractSeg -i tractseg_output/peaks.nii.gz -o tractseg_output --output_type TOM --super_resolution
Here is the error text: _/home/w/anaconda3/envs/torch_2023/bin/TractSeg:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html import('pkg_resources').require('TractSeg==2.9') Loading weights from: /home/w/.tractseg/pretrained_weights_peak_regression_part1_v2.npz 100%|█████████████████████████████████████████| 144/144 [00:02<00:00, 63.55it/s] Loading weights from: /home/w/.tractseg/pretrained_weights_peak_regression_part2_v2.npz 100%|████████████████████████████████████████| 144/144 [00:01<00:00, 129.27it/s] Loading weights from: /home/w/.tractseg/pretrained_weights_peak_regression_part3_v2.npz 100%|████████████████████████████████████████| 144/144 [00:01<00:00, 130.46it/s] Loading weights from: /home/w/.tractseg/pretrained_weights_peak_regression_part4_v2.npz Traceback (most recent call last): File "/home/w/anaconda3/envs/torch_2023/bin/TractSeg", line 7, in exec(compile(f.read(), file, 'exec')) File "/home/w/soft/TractSeg/bin/TractSeg", line 420, in main() File "/home/w/soft/TractSeg/bin/TractSeg", line 325, in main seg = run_tractseg(data, args.output_type, File "/home/w/soft/TractSeg/tractseg/python_api.py", line 206, in run_tractseg model = BaseModel(Config, inference=True) File "/home/w/soft/TractSeg/tractseg/models/base_model.py", line 106, in init self.load_model(join(self.Config.EXP_PATH, self.Config.WEIGHTS_PATH)) File "/home/w/soft/TractSeg/tractseg/models/base_model.py", line 280, in load_model pytorch_utils.load_checkpoint(path, unet=self.net) File "/home/w/soft/TractSeg/tractseg/libs/pytorch_utils.py", line 20, in load_checkpoint checkpoint = torch.load(path, map_location=lambda storage, loc: storage) File "/home/w/anaconda3/envs/torch_2023/lib/python3.9/site-packages/torch/serialization.py", line 795, in load return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args) File "/home/w/anaconda3/envs/torch_2023/lib/python3.9/site-packages/torch/serialization.py", line 1020, in _legacy_load typed_storage._storage.set_from_file( RuntimeError: unexpected EOF, expected 31322553 more bytes. The file might be corrupted.
The Error in above processing causes further errors when I run the tracking: The code for tracking that I am running is: Tracking -i tractseg_output/peaks.nii.gz -o tractseg_output Here is the further error text: _/home/w/anaconda3/envs/torch_2023/bin/Tracking:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html import('pkg_resources').require('TractSeg==2.9') 75%|████████████████████████████████▎ | 54/72 [01:44<00:34, 1.94s/it] Traceback (most recent call last): File "/home/w/anaconda3/envs/torch_2023/lib/python3.9/site-packages/nibabel/loadsave.py", line 100, in load stat_result = os.stat(filename) FileNotFoundError: [Errno 2] No such file or directory: 'tractseg_output/TOM/T_PAR_left.nii.gz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/w/anaconda3/envs/torch_2023/bin/Tracking", line 7, in exec(compile(f.read(), file, 'exec')) File "/home/w/soft/TractSeg/bin/Tracking", line 168, in main() File "/home/w/soft/TractSeg/bin/Tracking", line 158, in main tracking.track(bundle, input_path, Config.PREDICT_IMG_OUTPUT, File "/home/w/soft/TractSeg/tractseg/libs/tracking.py", line 179, in track tom_peaks_img = nib.load(output_dir + "/" + TOM_folder + "/" + bundle + ".nii.gz") File "/home/w/anaconda3/envs/torch_2023/lib/python3.9/site-packages/nibabel/loadsave.py", line 102, in load raise FileNotFoundError(f"No such file or no access: '{filename}'") FileNotFoundError: No such file or no access: 'tractseg_output/TOM/T_PAR_left.nii.gz'_
How to solve this problem?
Thank you.
Probably your weights file got corrupted during download. Can you try to remove the directory ~/.tractseg? This will delete all the weights and then run again. Then all weights should be newly downlaoded.
Your suggestion is very useful to solve the above problem, thank you