Skip to content

Instantly share code, notes, and snippets.

@tashrifbillah
Last active May 15, 2020 15:44
Show Gist options
  • Save tashrifbillah/b2626093b277ce8cdb07455cd98910f4 to your computer and use it in GitHub Desktop.
Save tashrifbillah/b2626093b277ce8cdb07455cd98910f4 to your computer and use it in GitHub Desktop.
imgShape -- maskShape discrepancy
# run as python shape_check.py
from conversion import read_cases
import numpy as np
from nibabel import load
from os.path import isfile
# copy this script to DIAGNOSE_CTE_U01/derivatives/pnlpipe and run from there
# adjust caselist if necessary
cases=read_cases('../../caselists/Caselist_ALL.txt')
for i in cases:
imgPath= f'sub-{i}/ses-01/dwi/sub-{i}_ses-01_desc-Xc_dwi.nii.gz'
maskPath=f'sub-{i}/ses-01/dwi/sub-{i}_ses-01_desc-dwiXcCNNQc_mask.nii.gz'
if isfile(imgPath) and isfile(maskPath):
img= load(imgPath)
mask= load(maskPath)
imgShape= img.header.get_data_shape()[:-1]
maskShape= mask.header.get_data_shape()
if not np.allclose(imgShape, maskShape):
print(i)
# comment out the following if just caselist is of interest
print('imgShape', imgShape)
print('maskShape', maskShape)
print('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment