-
Notifications
You must be signed in to change notification settings - Fork 29
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
RadQy Dimension Error with Diffusion Weighted Imaging #45
Comments
Thank you for using RadQy and reporting this issue! The error occurs because plt.imsave does not handle 4D data (e.g., multi-volume scans). To resolve this, you can update the save_image function to process each volume and slice individually. Here’s the fixed code: def save_image(self, participant, I, index, folder):
|
Thank you for the solution. This update appears to have worked. Unfortunately, we have run into another error stemming from the shape of the DWI images. Since the error is saying that the function is expecting 2D arrays, I'd guess that the DWI images have 3D arrays that are not compatible. The error message is as follows: Traceback (most recent call last): Any help in solving this issue would be greatly appreciated. |
Apologies, did not mean to close the issue. |
Hello, my team and I are attempting to run radqy on our BIDS dataset (nii.gz - compressed nifti files). So far the tool is able to process our anatomical scans, but we are hitting an issue with our diffusion weighted imaging (dwi) scans. For dwi scans with just one volume, there is no issue. But for our dwi scans with more than one volume, we get the following error:
Traceback (most recent call last):
File ".../radqy-0.1.5/bin/radqy", line 8, in
sys.exit(run_cli())
File ".../radqy-0.1.5/lib/python3.10/site-packages/radqy/cli.py", line 44, in run_cli
main(args)
File ".../radqy-0.1.5/lib/python3.10/site-packages/radqy/radqy.py", line 616, in main
s = IQM(v, name, total_participants, participant_index, subject_type, total_tags, fname_outdir, save_masks_flag,functions, sample_size, scan_type)
File ".../radqy-0.1.5/lib/python3.10/site-packages/radqy/radqy.py", line 452, in init
self.save_image(participant, I, j, folder)
File ".../radqy-0.1.5/lib/python3.10/site-packages/radqy/radqy.py", line 482, in save_image
plt.imsave(image_path, I, cmap=cm.Greys_r)
File ".../radqy-0.1.5/lib/python3.10/site-packages/matplotlib/pyplot.py", line 2604, in imsave
matplotlib.image.imsave(fname, arr, **kwargs)
File ".../radqy-0.1.5/lib/python3.10/site-packages/matplotlib/image.py", line 1636, in imsave
rgba = sm.to_rgba(arr, bytes=True)
File ".../radqy-0.1.5/lib/python3.10/site-packages/matplotlib/cm.py", line 399, in to_rgba
raise ValueError("Third dimension must be 3 or 4")
ValueError: Third dimension must be 3 or 4
It appears to be an issue creating the .pngs where the dimensions of the nifti files are not compatible with RGB or RGB-A format, but again, only when the scan has multiple volumes. Investigating the shape of the scans using a python tool called nibabel gives the following:
single volume scan shape: (140, 140, 22)
multiple volume (5) scan shape: (160, 160, 22, 5)
Have you encountered this error before? Do you know of a work around or fix? Thanks.
The text was updated successfully, but these errors were encountered: