Skip to content
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

Histogram standardization changes image shape after transformation #933

Open
1 task done
kondratevakate opened this issue Jul 15, 2022 · 4 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@kondratevakate
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Bug summary

So I am learning landmarks and applyiong for the dataset TCIA GBM (102 subjects, T1, T2,FLAIR and CT1)

And on the one subject TCGA-06-0142 for all images after transformation I will get different image shape. Which was not planned :)

Original:

	 Pixel Type : float (float32)
	 Components : 1
	 Dimensions : (240, 240, 168)
	 Spacing    : (1.0, 1.0, 1.0)
	 Origin     : (-121.5, 109.6625, -92.1)
	 Direction  : [ 1.  0.  0.  0. -1.  0.  0.  0.  1.]```

After Histogram standartization:
```ANTsImage (RPI)
	 Pixel Type : float (float32)
	 Components : 1
	 Dimensions : (200, 200, 150)
	 Spacing    : (1.0, 1.0, 1.0)
	 Origin     : (-100.0, 102.3187, -53.5)
	 Direction  : [ 1.  0.  0.  0. -1.  0.  0.  0.  1.]```


Original image has artefact - ghosting, so I suppose, histogram standartisation will crop it out, am I correct? 

![image](https://user-images.githubusercontent.com/34157226/179226219-c24f5836-02c2-42de-a849-c013a4f8c436.png)


### Code for reproduction

```python
t1_landmarks = HistogramStandardization.train(temp_t1_list)
hist_standardize = tio.HistogramStandardization(landmarks_dict)
hist_standard = hist_standardize(subjects_list[i])
hist_standard['t1'].save('/T1.nii.gz')

Actual outcome

Outputs image with cropped size

Error messages

No

Expected outcome

Will output the image of original space

System info

No response

@kondratevakate kondratevakate added the bug Something isn't working label Jul 15, 2022
@fepegar
Copy link
Owner

fepegar commented Jul 16, 2022

Thanks, @kondratevakate. This is very strange. Could you please share some data and code to reproduce?

@kondratevakate
Copy link
Author

Original image:
image

Image after histogram standartization:
image

Attaching files and landmarks

@kondratevakate
Copy link
Author

Any updates on that? I am getting the same problem in other datasets - it change the shape after the transformation.

@fepegar
Copy link
Owner

fepegar commented Aug 11, 2022

Can you please share a code snippet I can run to reproduce the issue? I can't reproduce with what you've shared:

In [1]: import torch

In [2]: landmarks = torch.load('gbm_dict.pth')

In [4]: import torchio as tio

In [5]: subject = tio.Subject(ct1=tio.ScalarImage('CT1_orig.nii.gz'))

In [6]: transform = tio.HistogramStandardization(landmarks)

In [7]: subject.shape
Out[7]: (1, 240, 240, 168)

In [8]: transform(subject).shape
Out[8]: (1, 240, 240, 168)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants