Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/CODE/dtiQA_v7/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ def pescheme2axis(pe_axis, pe_dir, aff):

# Function Definitions: Visualization

def slice_nii(nii_file, offsets=[0], custom_aff=[], min_percentile=0, max_percentile=100, min_intensity=np.nan, max_intensity=np.nan, det=False):
def slice_nii(nii_file, offsets=False, custom_aff=[], min_percentile=0, max_percentile=100, min_intensity=np.nan, max_intensity=np.nan, det=False):

if det:
img, aff, hdr = load_nii(nii_file, ndim=4)
Expand Down Expand Up @@ -782,10 +782,20 @@ def slice_nii(nii_file, offsets=[0], custom_aff=[], min_percentile=0, max_percen
i1 = int(round(img.shape[1] / 2, 1))
i2 = int(round(img.shape[2] / 2, 1))

if offsets:
slice1 = int(round(i2 * 0.3, 1))
slice2 = int(round(i2 * 0.4, 1))
slice3 = int(round(i2 * 0.5, 1))
slice4 = int(round(i2 * 0.6, 1))
slice5 = int(round(i2 * 0.7, 1))
offset_value = [ slice1, slice2, slice3, slice4, slice5 ]
else:
offset_value = [0]

i0s = []
i1s = []
i2s = []
for offset in offsets:
for offset in offset_value:
i0s.append(i0 + offset)
i1s.append(i1 + offset)
i2s.append(i2 + offset)
Expand Down
6 changes: 3 additions & 3 deletions src/CODE/dtiQA_v7/vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def vis_degibbs(dwi_files, bvals_files, dwi_degibbs_files, gains, vis_dir):

# Plot 5 central triplanar views

res_slices, res_vox_dim, res_min, res_max = utils.slice_nii(res_file, offsets=[-10, -5, 0, 5, 10], min_intensity=0, max_percentile=99)
res_slices, res_vox_dim, res_min, res_max = utils.slice_nii(res_file, offsets=True, min_intensity=0, max_percentile=99)
temp_vis_file = _vis_vol(res_slices, res_vox_dim, res_min, res_max, temp_dir, name='Gibbs_Deringing,_Averaged_Residuals_of_b_=_0_Volumes', comment='Residuals should be larger at high-contrast interfaces', colorbar=False)
degibbs_vis_file = utils.rename_file(temp_vis_file, os.path.join(vis_dir, 'degibbs.pdf'))

Expand Down Expand Up @@ -949,7 +949,7 @@ def vis_dwi(dwi_file, bvals_shelled, bvecs_file, cnr_dict, vis_dir):
bX = bvals[i]
bXs_file, num_bXs, _ = utils.dwi_extract(dwi_file, bvals_shelled_file, temp_dir, target_bval=bX, first_only=False)
bXs_avg_file = utils.dwi_avg(bXs_file, temp_dir)
bXs_avg_slices, bXs_avg_vox_dim, bXs_avg_min, bXs_avg_max = utils.slice_nii(bXs_avg_file, offsets=[-10, -5, 0, 5, 10], min_intensity=0, max_percentile=SHARED_VARS.VIS_PERCENTILE_MAX)
bXs_avg_slices, bXs_avg_vox_dim, bXs_avg_min, bXs_avg_max = utils.slice_nii(bXs_avg_file, offsets=True, min_intensity=0, max_percentile=SHARED_VARS.VIS_PERCENTILE_MAX)

cnr = '{:.3f}'.format(cnr_dict[bX])
cnr_label = 'SNR' if bX == 0 else 'CNR'
Expand All @@ -974,7 +974,7 @@ def vis_scalar(scalar_file, vis_dir, name='?', comment=''):
elif name == 'MD':
scalar_max = SHARED_VARS.ADC_WATER

scalar_slices, scalar_vox_dim, _, _ = utils.slice_nii(scalar_file, offsets=[-10, -5, 0, 5, 10])
scalar_slices, scalar_vox_dim, _, _ = utils.slice_nii(scalar_file, offsets=True)
scalar_vis_file = _vis_vol(scalar_slices, scalar_vox_dim, scalar_min, scalar_max, vis_dir, name=name, comment=comment, colorbar=True)

return scalar_vis_file
Expand Down