Skip to content

Commit

Permalink
Merge pull request #7 from AlexBowring/resubmission_two
Browse files Browse the repository at this point in the history
Resubmission two
  • Loading branch information
AlexBowring authored Nov 20, 2018
2 parents bd5d8e7 + a71bd79 commit c8811f6
Show file tree
Hide file tree
Showing 29 changed files with 292 additions and 241 deletions.
204 changes: 96 additions & 108 deletions figures/ds001_notebook.ipynb

Large diffs are not rendered by default.

190 changes: 94 additions & 96 deletions figures/ds109_notebook.ipynb

Large diffs are not rendered by default.

67 changes: 33 additions & 34 deletions figures/ds120_notebook.ipynb

Large diffs are not rendered by default.

Binary file modified figures/img/Fig_ds001_BA_AFNI_FSL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_BA_AFNI_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_BA_FSL_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_bold_BA_AFNI_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_bold_BA_FSL_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_bold_BOLD_AFNI_FSL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_perm_BA_AFNI_FSL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_perm_BA_AFNI_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_perm_BA_FSL_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_permintra_BA_AFNI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_permintra_BA_FSL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds001_permintra_BA_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_BA_AFNI_FSL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_BA_AFNI_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_BA_FSL_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_bold_BA_AFNI_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_bold_BA_FSL_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_bold_BOLD_AFNI_FSL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_perm_BA_AFNI_FSL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_perm_BA_AFNI_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_perm_BA_FSL_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_permintra_BA_AFNI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_permintra_BA_FSL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds109_permintra_BA_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figures/img/Fig_ds120_BA_AFNI_SPM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 69 additions & 3 deletions figures/lib/bland_altman.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ def mask_using_nan(data_img):
return(data_img_nan)


def squeeze_four_d_image(data_img):
# Set masking using NaN's
data_orig = data_img.get_data()
data_three_d = data_orig[:,:,:,0]
data_img_three_d = nib.Nifti1Image(data_three_d, data_img.get_affine())

return(data_img_three_d)

# Getting white matter and csf images to mask out from BA plots
fsldir = os.environ['FSLDIR']
white_matter = os.path.join(fsldir, 'data', 'standard', 'tissuepriors', 'avg152T1_white.img')
white_matter_img = nib.load(white_matter)
white_matter_img = mask_using_nan(white_matter_img)
white_matter_img = squeeze_four_d_image(white_matter_img)

csf = os.path.join(fsldir, 'data', 'standard', 'tissuepriors', 'avg152T1_csf.img')
csf_img = nib.load(csf)
csf_img = mask_using_nan(csf_img)
csf_img = squeeze_four_d_image(csf_img)

def bland_altman_values(data1_file, data2_file, reslice_on_2=True,
*args, **kwargs):

Expand All @@ -54,22 +74,45 @@ def bland_altman_values(data1_file, data2_file, reslice_on_2=True,
if reslice_on_2:
# Resample data1 on data2 using nearest nneighbours
data1_resl_img = resample_from_to(data1_img, data2_img, order=0)

white_matter_resl_img = resample_from_to(white_matter_img, data2_img, order=0)
csf_resl_img = resample_from_to(csf_img, data2_img, order=0)

# Load data from images
data1 = data1_resl_img.get_data()
data2 = data2_img.get_data()
white_matter = white_matter_resl_img.get_data()
csf = csf_resl_img.get_data()
else:
# Resample data2 on data1 using nearest nneighbours
data2_resl_img = resample_from_to(data2_img, data1_img, order=0)
white_matter_resl_img = resample_from_to(white_matter_img, data1_img, order=0)
csf_resl_img = resample_from_to(csf_img, data1_img, order=0)

# Load data from images
data1 = data1_img.get_data()
data2 = data2_resl_img.get_data()

white_matter = white_matter_resl_img.get_data()
csf = csf_resl_img.get_data()

# Masking white matter and csf images for a threshold of 0.5
white_matter_mask = white_matter >= 0.5
white_matter_mask = white_matter_mask*1
csf_mask = csf >= 0.5
csf_mask = csf_mask*1

# Vectorise input data
data1 = np.reshape(data1, -1)
data2 = np.reshape(data2, -1)

white_matter_mask = np.reshape(white_matter_mask, -1)
csf_mask = np.reshape(csf_mask, -1)

not_white_matter_csf_indices = np.logical_not(
np.logical_or(
white_matter_mask == 1, csf_mask == 1))

data1 = data1[not_white_matter_csf_indices]
data2 = data2[not_white_matter_csf_indices]

in_mask_indices = np.logical_not(
np.logical_or(
np.logical_or(np.isnan(data1), np.absolute(data1) == 0),
Expand Down Expand Up @@ -351,21 +394,44 @@ def scatter_values(data1_file, data2_file, reslice_on_2=True,
if reslice_on_2:
# Resample data1 on data2 using nearest nneighbours
data1_resl_img = resample_from_to(data1_img, data2_img, order=0)
white_matter_resl_img = resample_from_to(white_matter_img, data2_img, order=0)
csf_resl_img = resample_from_to(csf_img, data2_img, order=0)

# Load data from images
data1 = data1_resl_img.get_data()
data2 = data2_img.get_data()
white_matter = white_matter_resl_img.get_data()
csf = csf_resl_img.get_data()
else:
# Resample data2 on data1 using nearest nneighbours
data2_resl_img = resample_from_to(data2_img, data1_img, order=0)
white_matter_resl_img = resample_from_to(white_matter_img, data1_img, order=0)
csf_resl_img = resample_from_to(csf_img, data1_img, order=0)

# Load data from images
data1 = data1_img.get_data()
data2 = data2_resl_img.get_data()
white_matter = white_matter_resl_img.get_data()
csf = csf_resl_img.get_data()

# Masking white matter and csf images for a threshold of 0.5
white_matter_mask = white_matter >= 0.5
white_matter_mask = white_matter_mask*1
csf_mask = csf >= 0.5
csf_mask = csf_mask*1

# Vectorise input data
data1 = np.reshape(data1, -1)
data2 = np.reshape(data2, -1)
white_matter_mask = np.reshape(white_matter_mask, -1)
csf_mask = np.reshape(csf_mask, -1)

not_white_matter_csf_indices = np.logical_not(
np.logical_or(
white_matter_mask == 1, csf_mask == 1))

data1 = data1[not_white_matter_csf_indices]
data2 = data2[not_white_matter_csf_indices]

in_mask_indices = np.logical_not(
np.logical_or(
Expand Down

0 comments on commit c8811f6

Please sign in to comment.