Converting RDS to LDS?
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Problem summary
I am attempting to follow the workflow you used for https://github.com/fepegar/torchio/issues/647 , but I am still getting issues. I am loading from two different data sources for semantic segmentation one .nii and one .npy. When I run it through the transformation below and call the first time of the training set I get an error. Thank you in advance.
Code for reproduction
def numpy_reader(path):
return np.load(path), np.eye(4)
subjects=[]
for subject_path in merged_list:
subject = tio.Subject({"MRI":tio.ScalarImage(subject_path[0]), "Label":tio.LabelMap(subject_path[1],reader=numpy_reader)})
subjects.append(subject)
process = tio.Compose([
tio.ToCanonical(),
tio.CropOrPad((192, 192, 192)), #This crops it to the desired metirc
tio.RescaleIntensity((-1, 1)) # This normalizes the data
])
augmentation = tio.RandomAffine(scales=(0.9, 1.1), degrees=(-10, 10))
val_transform = process
train_transform = tio.Compose([process, augmentation])
train_dataset = tio.SubjectsDataset(subjects, transform=train_transform)
val_dataset = tio.SubjectsDataset(subjects, transform=val_transform)
train_dataset[0] #error
Actual outcome
I get an error that says my two images are in different space which is true from my run-through.
When I check to see how different they look very similar
Error messages
RuntimeError: More than one value for "direction" found in subject images:
{'Label': (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0),
'MRI': (-1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)}
....
RuntimeError: As described above, some images in the subject are not in the same space. You probably can use the transforms ToCanonical and Resample to fix this, as explained at https://github.com/fepegar/torchio/issues/647#issuecomment-913025695
Expected outcome
Subject(Keys: (‘MRI’, ‘Label’); images: 2)
System info
# flake8: noqa
import re
import sys
import platform
import torchio
import torch
import numpy
import SimpleITK as sitk
sitk_version = re.findall('SimpleITK Version: (.*?)\n', str(sitk.Version()))[0]
print('Platform: ', platform.platform())
print('TorchIO: ', torchio.__version__)
print('PyTorch: ', torch.__version__)
print('SimpleITK: ', sitk_version)
print('NumPy: ', numpy.__version__)
print('Python: ', sys.version)
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Comparison of the Community of Christ and the Church of ...
Community of Christ and the Church of Jesus Christ of Latter-day Saints (LDS Church) are two denominations that share a common heritage in...
Read more >LDS+RDS(or other xDS transitively owned by listenerImpl ...
RDS propagates a configUpdate to workers, the posted callback is as following: tls_->runOnAllThreads(
Read more >Conversion - The Church of Jesus Christ of Latter-day Saints
Conversion includes a change in behavior, but it goes beyond behavior; it is a change in our very nature. It is such a...
Read more >Conversion - The Church of Jesus Christ of Latter-day Saints
Characteristics of People Who Are Converted. The Book of Mormon provides descriptions of people who are converted to the Lord: They desire to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t know what changed but my error has moved to: RuntimeError: More than one value for “origin” found in subject images: {‘Label’: (0.0, 0.0, 0.0), ‘MRI’: (-91.0, -126.0, -72.0)} I’ll look into this further
Thanks for the info. In that case, that’s definitely the issue. I would stick to a format more suitable for medical images such as NIfTI or NRRD.