Skip to content

Commit a3e8620

Browse files
committed
FIX: avoid including pixdim[0]/qfac in voxel volume calculation
1 parent c68973e commit a3e8620

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

pyxnat/core/derivatives/bamos.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def volume(self):
2929
f = list(self.files('CorrectLesion_*nii.gz'))[0]
3030
f.get(fp)
3131
d = nib.load(fp)
32-
size = np.prod(d.header['pixdim'].tolist()[:4])
32+
size = np.prod(d.header['pixdim'].tolist()[1:4])
3333
n = np.array(d.dataobj)
3434
v = np.sum(n[n >= 0.5]) * size
3535
os.remove(fp)
@@ -66,7 +66,7 @@ def _download_data_(self):
6666
f = list(self.files('CorrectLesion_*nii.gz'))[0]
6767
f.get(fp)
6868
d = nib.load(fp)
69-
size = np.prod(d.header['pixdim'].tolist()[:4])
69+
size = np.prod(d.header['pixdim'].tolist()[1:4])
7070
les = np.array(d.dataobj)
7171

7272
f = list(self.files('Layers_*.nii.gz'))[0]

pyxnat/core/derivatives/basil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def volumes(self):
1717
f = self.files('*{}*'.format(kls))[0]
1818
f.get(fp)
1919
d = nib.load(fp)
20-
size = np.prod(d.header['pixdim'].tolist()[:4])
20+
size = np.prod(d.header['pixdim'].tolist()[1:4])
2121
v = np.sum(d.dataobj) * size
2222
vols.append((kls, v))
2323

pyxnat/core/derivatives/cat12.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def volumes(self):
1616
f = [each for each in self.files() if each.id().startswith(kls)][0]
1717
f.get(fp)
1818
d = nib.load(fp)
19-
size = np.prod(d.header['pixdim'].tolist()[:4])
19+
size = np.prod(d.header['pixdim'].tolist()[1:4])
2020
v = np.sum(d.dataobj) * size
2121
vols.append((kls, v))
2222

pyxnat/core/derivatives/fsl_anat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def subcortical_volumes(self):
4141
f.get(fp)
4242
img = nib.load(fp)
4343
data = np.asarray(img.dataobj)
44-
voxel_size = np.prod(img.header['pixdim'].tolist()[:4])
44+
voxel_size = np.prod(img.header['pixdim'].tolist()[1:4])
4545

4646
for roi, label in labels.items():
4747
volume = np.count_nonzero(data == label) * voxel_size

pyxnat/core/derivatives/spm12.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def volumes(self):
1616
f = [each for each in self.files() if each.id().startswith(kls)][0]
1717
f.get(fp)
1818
d = nib.load(fp)
19-
size = np.prod(d.header['pixdim'].tolist()[:4])
19+
size = np.prod(d.header['pixdim'].tolist()[1:4])
2020
v = np.sum(d.dataobj) * size
2121
vols.append((kls, v))
2222

0 commit comments

Comments
 (0)