-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch issue #79 and get_bdata function
- Loading branch information
Showing
2 changed files
with
32 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ class BrukerLoader(): | |
get_affine(scan_id, reco_id) | ||
return affine transform matrix | ||
get_bdata(scan_id, reco_id) | ||
return bmat, bvec, bval as string | ||
return bvals, bvecs, as string | ||
get_scan_time(visu_pars=None) | ||
return dictionary contains the datetime object for session initiate time | ||
if visu_pars parameter object is given, it will contains scan start time | ||
|
@@ -457,25 +457,29 @@ def save_nifti(self, scan_id, reco_id, filename, dir='./', ext='nii.gz', | |
# - FSL bval, bvec, and bmat | ||
def save_bdata(self, scan_id, filename, dir='./'): | ||
method = self._method[scan_id] | ||
bval, bvec, bmat = self._get_bdata(method) | ||
# bval, bvec, bmat = self._get_bdata(method) # [220201] bmat seems not necessary | ||
bvals, bvecs = self._get_bdata(method) | ||
output_path = os.path.join(dir, filename) | ||
|
||
with open('{}.bval'.format(output_path), 'w') as bval_fobj: | ||
for item in bval: | ||
bval_fobj.write("%f " % item) | ||
bval_fobj.write("\n") | ||
# for item in bval: # [220201] correct the format | ||
# bval_fobj.write("%f " % item) | ||
# bval_fobj.write("\n") | ||
bval_fobj.write(' '.join(bvals.astype('str')) + '\n') | ||
|
||
with open('{}.bvec'.format(output_path), 'w') as bvec_fobj: | ||
for row in bvec: | ||
for item in row: | ||
bvec_fobj.write("%f " % item) | ||
bvec_fobj.write("\n") | ||
|
||
with open('{}.bmat'.format(output_path), 'w') as bmat_fobj: | ||
for row in bmat: | ||
for item in row.flatten(): | ||
bmat_fobj.write("%s " % item) | ||
bmat_fobj.write("\n") | ||
# for row in bvec: # [220201] correct the format | ||
# for item in row: | ||
# bvec_fobj.write("%f " % item) | ||
# bvec_fobj.write("\n") | ||
for row in bvecs: | ||
bvec_fobj.write(' '.join(row.astype('str')) + '\n') | ||
|
||
# with open('{}.bmat'.format(output_path), 'w') as bmat_fobj: # [220201] remove bmat | ||
# for row in bmat: | ||
# for item in row.flatten(): | ||
# bmat_fobj.write("%s " % item) | ||
# bmat_fobj.write("\n") | ||
|
||
# BIDS JSON | ||
def _parse_json(self, scan_id, reco_id, metadata=None): | ||
|
@@ -648,7 +652,7 @@ def info(self, io_handler=None): | |
for i, (scan_id, recos) in enumerate(self._avail.items()): | ||
for j, reco_id in enumerate(recos): | ||
visu_pars = self._get_visu_pars(scan_id, reco_id) | ||
if i == 0: | ||
if i == 0 and j == 0: | ||
sw_version = get_value(visu_pars, 'VisuCreatorVersion') | ||
|
||
title = 'Paravision {}'.format(sw_version) | ||
|
@@ -810,10 +814,17 @@ def _get_temp_info(self, visu_pars): | |
# DTI | ||
@staticmethod | ||
def _get_bdata(method): | ||
bval = get_value(method, 'PVM_DwEffBval') | ||
bvec = get_value(method, 'PVM_DwGradVec').T # to have three rows instead of three columns | ||
bmat = get_value(method, 'PVM_DwBMat') | ||
return bval, bvec, bmat | ||
# [220201] parse the input value directly instead of final values & remove bmat | ||
# bval = get_value(method, 'PVM_DwEffBval') | ||
# bvec = get_value(method, 'PVM_DwGradVec').T # to have three rows instead of three columns | ||
# bmat = get_value(method, 'PVM_DwBMat') | ||
# return bval, bvec, bmat | ||
bval = get_value(method, 'PVM_DwBvalEach') | ||
num_b0 = get_value(method, 'PVM_DwAoImages') | ||
num_dir = get_value(method, 'PVM_DwNDiffExp') | ||
bvals = np.r_[np.zeros(num_b0), np.ones(num_dir - num_b0) * bval] | ||
bvecs = np.r_[np.zeros([num_b0, 3]), get_value(method, 'PVM_DwDir')].T | ||
return bvals, bvecs | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gdevenyi
Collaborator
|
||
|
||
# Generals | ||
@staticmethod | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@dvm-shlee: was there a good reason to switch from effective diffusion b-values and b-vec (PVM_DwEffBval and PVM_DwGradVec) to the requested ones (PVM_DwBvalEach and PVM_DwDir)?
I would argue that the effective values are much more useful than the requested ones.
Also, the requested parameters do not hold the b0 scans, and the way this is handled here does not account correctly for b0 scans at any other place than at the beginning of the diffusion scheme. This led to issue #90.
I'd suggest going back to the effective parameters, as @araikes suggested in issue #90.