Closed DANAJK closed 2 years ago
I guess we need to use numpy expand_dims
Something like this might work
vol = np.expand_dims(vol, axis=0)
Also the BrainWeb notebook
I changed the BrainWeb-single_slice_motion.ipynb notebook. @DANAJK is right, the same function is implemented in the BrainWeb notebook. It deals with the entire 3D array rather than cropping to a 2D image, though, so the error doesn't occur in the BrainWeb notebook for me.
BrainWeb-single_slice_motion.ipynb
After
FDG_arr = vol['PET']
, the shape ofFDG_arr
is (127,344,344).Then after slice = FDG_arr.shape[0]//2 FDG_arr = FDG_arr[slice,:,:]
FDG_arr
has shape (344,344) (i.e. there has been a secret squeeze). This subsequently causes problems withim.fill(vol)
becausevol
is derived fromFDG_arr
and is thus 2D (despite the namevol
), whereasim
is 3D (despite the name) and has a singleton first dimension so you can't fillim
withvol
.