Comments (9)
It is more robust (for other software) to set both sform and qform
For which software? ITK saves images like this by default and I've had trouble before due to qform and sform being different, and for example NiftyReg and Slicer using one or the other as default.
from torchio.
Well I do not remember, but I notice some problem in the past with data having only one of the sform or the qform set
To have 2 transform in the nifty header is probably the worst idea for this format, and it confuse a lot and it is source of hidden bugs. So the best way to avoid confusion is to always set the both to the identical affine.
My point is that I do not see any argument for not setting the sform ... it will just be more robust and it won't disturb other software to have it set
Actually spm is the only software I know that use those 2 transform differently : when you do a coregister, spm is modifying the sform (only) and keep the qform unchanged
Note that for such volume when you read them with nibabel, the affine read is the sform (so it is consistent with spm) (although nii.get_sform and nii.get_qform is returning 2 differents affines as it is written in the header)
For such volume as input I would say we should generate identical output header (ie with 2 different affine)
For now since we only store internally the affine (comming from the sform) we can not do it, It is not a big deal in my point of view, since at the end we only want to consider the correct affine. (in the case of volume modified by spm coregister, the correct affine to consider is the sform, and this is the default of nibabel, so every thing is fine) we will just ovewrite the qform, (which I still do not understand how it should be used ...)
So I insist, let write the sform too ... no ?
from torchio.
I notice some problem in the past with data having only one of the sform or the qform set
I've had trouble when only the sform
is set. Using only the qform
and setting the sform_code
to 0 ensures that there's a unique, valid, rigid transformation in the header.
when you read them with nibabel, the affine read is the sform
This is not necessarily true: https://nipy.org/nibabel/nifti_images.html#choosing-the-image-affine
It depends on the sform_code
and qform_code
. The system I implemented here is the one used by default in ITK.
Anyway, the write
functions in io
are not a central part of this project, so I don't think it has a big impact.
from torchio.
As you want, your solution is correct, and coherent within torchio.
(I'll just change the corresponding line, in my fork, it is not a big deal
from torchio.
Out of curiosity: are you using the ImagesDataset.save_sample
method? I thought it wouldn't be used often. I mostly use it for developing purposes.
from torchio.
Well to be honest, for now I just play around with transform, and I still did not start using it for training a network (it will come soon)
I am afraid, some transformation will take too much times, (motion elastic deformation can takes several second, so compositions will become around 10 seconds.
I am still not sure yet, but one solution would be to perform all augmentation once and write them to the disk ...
(doing this way I could use a cluster environment to perform it in parallel on the different inputs data)
What about you, is the 10 second for each volume not too long for training ?
from torchio.
but an other useful use will be when you want to set the transform parameters, you need to perform them and look at saved transform
So I find this is a very important and useful function
from torchio.
I'm training on an NVIDIA DGX with 40 cores, so I'm not too worried about that because everything is very parallel. Also, I'm not using the queue at the moment so the data loaders are nicely filled in the background continuously. I set proportion_to_augment
to 0.1 for RandomMotion
and RandomElasticDeformation
, and 0.25 for RandomBiasField
. Loading uncompressed files is also faster, if you can afford the storage.
from torchio.
but an other useful use will be when you want to set the transform parameters, you need to perform them and look at saved transform
Good point. That's why I added the CLI tool:
$ torchio-transform input.nii.gz RandomMotion output.nii.gz
It's still a work in progress, I need to adapt it so that it accepts the kwargs
for the transform.
5a4331a
from torchio.
Related Issues (20)
- Proposal of a new way for DDP, Distributed Sampler, and Queue to work HOT 3
- Tests for queue are failing on Windows HOT 1
- Pad modifies labels unexpectedly HOT 4
- Torchio Transformation Does not Working properly HOT 2
- `masked_select` on Z-Normalization slower than indexing HOT 2
- GridSampler without subject for validation HOT 3
- Resize sometimes adds a dimension to LabelMap images HOT 5
- Documentation is not built
- Patch Based Training With Queue Is Not Working Properly HOT 1
- Error when using a lambda function as masking_method in ZNormalization HOT 2
- Combined Affine/Elastic augmentations HOT 1
- The rotation given by Random Affine not accurate HOT 5
- (Optional) state_dict for each transform (reproducibility) HOT 2
- Wrong link to docs in Getting Started tutorial HOT 2
- Suggestions the modifying default value of prefetch_factor and the argument to set it for minimize the blocking-bottleneck between fetch subject and generate patch in Queue HOT 1
- Different transforms applied to CT and label HOT 11
- The Affine matrix does not change after applying the augmentations HOT 3
- Custom loader not used when loading data lazily HOT 2
- Seed is not working HOT 2
- Silenced exception makes it harder to debug custom Transforms HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torchio.