Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/shell_as_G-Delta-delta-TE #76

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion amico/lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def load_precomputed_rotation_matrices( lmax = 12 ) :
filename = pjoin( dipy_home, 'AMICO_aux_matrices_lmax=%d.pickle'%lmax )
if not isfile( filename ) :
raise RuntimeError( 'Auxiliary matrices not found; call "lut.precompute_rotation_matrices()" first.' )
return pickle.load( open(filename,'rb') )
return pickle.load( open(filename,'rb'),encoding='latin1' )


def aux_structures_generate( scheme, lmax = 12 ) :
Expand Down
33 changes: 15 additions & 18 deletions amico/scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,27 @@ def load_from_table( self, data, b0_thr = 0 ) :

# store information about each shell in a dictionary
self.shells = []

tmp = np.ascontiguousarray( self.raw[:,3:] )
schemeUnique, schemeUniqueInd = np.unique( tmp.view([('', tmp.dtype)]*tmp.shape[1]), return_index=True )
schemeUnique = schemeUnique.view(tmp.dtype).reshape((schemeUnique.shape[0], tmp.shape[1]))
schemeUnique = [tmp[index] for index in sorted(schemeUniqueInd)]
bUnique = [self.b[index] for index in sorted(schemeUniqueInd)]
for i in xrange(len(schemeUnique)) :
if bUnique[i] <= b0_thr :
continue

tmp1,tmp2 = np.unique(self.raw[:,3:],axis=0,return_index=True) # Find unique b-values or combinations of G, Delta, delta and TE (and the 1st index of each of those shells)
tmp1 = tmp1[self.b[tmp2] > 0,:] # Remove b0
tmp2 = tmp2[self.b[tmp2] > 0] # Remove b0
# For each shell, find its indexes, grad, b-value and shell parameters
for tmp3 in np.argsort(tmp2):
shell_features = tmp1[tmp3,:]
shell = {}
shell['b'] = bUnique[i]
if self.version == 0 :
shell['idx'] = np.where((self.raw[:,3:] == shell_features).all(axis=1))[0]
shell['grad'] = self.raw[shell['idx'],:3]
shell['b'] = np.unique(self.b[shell['idx']])[0]
if self.version == 0:
shell['G'] = None
shell['Delta'] = None
shell['delta'] = None
shell['TE'] = None
else :
shell['G'] = schemeUnique[i][0]
shell['Delta'] = schemeUnique[i][1]
shell['delta'] = schemeUnique[i][2]
shell['TE'] = schemeUnique[i][3]

shell['idx'] = np.where((tmp == schemeUnique[i]).all(axis=1))[0]
shell['grad'] = self.raw[shell['idx'],0:3]
shell['G'] = shell_features[0]
shell['Delta'] = shell_features[1]
shell['delta'] = shell_features[2]
shell['TE'] = shell_features[3]
self.shells.append( shell )


Expand Down