Which attributes does torchio.Subject check for?
#587
-
|
Hey, I was curious which attributes other than Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi, @sarthakpati.
You can take a look at the code for
It can:
If that's what you're checking for, yes. In [1]: import torch
In [2]: import torchio as tio
In [3]: import numpy as np
In [4]: x = torch.rand(1, 2, 3, 4)
In [5]: t1 = tio.ScalarImage(tensor=x, affine=np.diag((1, 1, 1, 1)))
In [6]: t2 = tio.ScalarImage(tensor=x, affine=np.diag((1, 1, 1.5, 1)))
In [7]: subject = tio.Subject(t1=t1, t2=t2)
In [8]: subject.shape
Out[8]: (1, 2, 3, 4)
In [9]: subject.spacing
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-9-08ec10953581> in <module>
----> 1 subject.spacing
~/git/torchio/torchio/data/subject.py in spacing(self)
132 (1.0, 1.0, 1.2999954223632812)
133 """
--> 134 self.check_consistent_attribute('spacing')
135 return self.get_first_image().spacing
136
~/git/torchio/torchio/data/subject.py in check_consistent_attribute(self, attribute)
227 f'\n{pprint.pformat(values_dict)}'
228 )
--> 229 raise RuntimeError(message)
230
231 def check_consistent_spatial_shape(self) -> None:
RuntimeError: More than one spacing found in subject images:
{'t1': (1.0, 1.0, 1.0), 't2': (1.0, 1.0, 1.5)} |
Beta Was this translation helpful? Give feedback.
Hi, @sarthakpati.
You can take a look at the code for
Subject:https://github.com/fepegar/torchio/blob/8b8791af3e9cd7e6bc45cc3bde3c124a3354c87b/torchio/data/subject.py#L218-L229
It can:
https://github.com/fepegar/torchio/blob/8b8791af3e9cd7e6bc45cc3bde3c124a3354c87b/torchio/data/subject.py#L121-L135
If that's what you're checking for, yes.