-
Notifications
You must be signed in to change notification settings - Fork 240
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
Add support for 4D images #238
Comments
Great There is no obvious difficulties for read write and sample since it is just adding multi-channel ... Here are just a few thought for what to do with transform For spatial transform : Although in the case of diffusion one may be interested, to produce different elastic transform (as there are small non linear deformation between diffusion volume) ... so may be the same option as for intensity ? For intensity transform: As an example for Motion, with diffusion or fMRI data one expect to have a different motion for each volume, but with a multi echo sequence, we expect the same motion for each volume It seem logical that for random_skipke we use a different one, but for random_bias the same for each channel ... but I suggest to let the user decide this may be quite a lot of code change in each transform ... |
Actually the same choice of behaviour should also be possible when multiple images are load in the subject sample For instance in randomAffine the same affine parameter is applied to all images (one could want a different one too) It would be great and flexible if this can also be a user choice (as input param of the transform) Because the choice of loading several 3D volume or one 4D volume will mainly be done depending of how the file are stored, but in this is 2 different internal representation of the same data ... so It make sens to have the same behavior |
Yes, this won't be easy! We need to plan this feature carefully. |
Would it be a good idea to add new subclasses of |
I've done most of the work. The parameters are computed per-channel, but I think it's good to merge that for now and we'll add support to have the choice later. @GFabien after merging this, could you refactor |
I agree. If I do this I may add a kwarg to choose the channels used to create the new image because I really like the modularity brought by the fact of having the labels as different keys in the sample. For example, in some of the models I'm currently running I use a |
Sounds good! |
FYI, most transforms seem ok: https://drive.google.com/file/d/1Gc8kzwKQR-bYA_ifqTnA6v0N5J_hPUeO/view?usp=sharing |
Sorry If I misunderstand, but I only had a quick look at the code, (i am in holiday ...) (from a physical point of view it makes sense to apply the same bias field to all 4D images, as it is what happen during the acquisition (if the subject is no moving too much into the coil) |
Salut Romain,
For now, I haven't made any choice. I just adapted
I think that's not what happens in the current implementation. I wrote to visualize the 4D transforms, look: https://colab.research.google.com/drive/1Gc8kzwKQR-bYA_ifqTnA6v0N5J_hPUeO#scrollTo=Dy2v05LPVCvA&line=2&uniqifier=1 I also think it should be the user's choice, but I won't have time to work on that anytime soon. Contributions are welcome, this shouldn't be difficult to implement for most of the transforms. |
Enjoy your holidays! |
Hi all, |
Hi, @meghbhalerao.
There's nothing one-hot-encoding-related in the library, but we could add it if necessary. You can use Note that you can now use the |
Thanks for the clarification @fepegar! |
🚀 Feature
Add support to read, write, sample and transform 4D images.
Motivation
It would be convenient to support 4D images out of the box, as tensors of shape (C, S1, S2, S3) where C is the number of channels and SX are spatial dimensions (S1 = 1 for 2D images).
Examples of what the 4th dimension might encode
Gradient directions
Time
Modalities or MRI sequences
EM frequency bands
Labels
Pitch
Support of 4D images in:
torchio.Image
torchio.io
Alternatives
Pass the channels independently in different instances of
Image
.Additional context
Considerations
torchio.io
Possible image shapes when reading
How do we know if 2D or 3D when there are 3 dimensions in the read data? Lookup table of file extensions?
2D
3D
Transforms
Consider whether to apply the same or different transformations to each channel of each image, as pointed out by @romainVala in #238 (comment).
Related issues
GridAggregator
torchio.Image
torchio.Subject
- mask with multiple masks and different shapes than imageThe text was updated successfully, but these errors were encountered: