Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into main
  • Loading branch information
SD3004 committed May 4, 2022
2 parents 57023e6 + b6473b2 commit 57d1831
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions conversion_image_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@


#### Load gifti image using nibabel ####
#image = nb.load('/data/Data/data_release_gDL_benchmarking/Data/Regression/Native_Space/regression_native_space_features/sub-CC00051XX02_ses-7702_L.shape.gii')
image = nb.load('/home/sd20/data/dHCP/merged_metrics/ico6_template/original/CC01215XX11_146331_right_merged.shape.gii')
filename = '' ### Participant to modify
image = nb.load(filename)

#### Define number of channels in gifti ####
channels=4
channels=4 ### Each channel represents a structural cortical metric (myelin, curvature, cortical thickness and sulcal depth - in that order)

img_array=[]

Expand All @@ -28,19 +28,21 @@
img_array.append(array)


#### Swap axes so that img_array dim is 40962,4 ####
#img_array = np.swapaxes(img_array, 0,1)
#### Swap axes so that img_array dim is 40962,4 - this will depend on how participants want to work with the image arrays ####
img_array = np.swapaxes(img_array, 0,1)


#### Create .mha image using sitk ####
mha_img = sitk.GetImageFromArray(img_array)

new_filename='' ### Participant to modify

#### Write out .mha image ####
sitk.WriteImage(mha_img,'/home/sd20/workspace/SLCN_algorithm/test/sub-CC01215XX111_ses-14633_L.mha')
sitk.WriteImage(mha_img, new_filename)

#### Read in .mha image again ####
mha_img1 = sitk.ReadImage('/home/sd20/workspace/SLCN_algorithm/test/sub-CC01215XX111_ses-14633_L.mha')
mha_img1 = sitk.ReadImage(new_filename)


#### Get array from image using sitk ####
img1_array = sitk.GetArrayFromImage(mha_img1)
img1_array = sitk.GetArrayFromImage(mha_img1)

0 comments on commit 57d1831

Please sign in to comment.