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

Already on GitHub? Sign in to your account

Gradients Table class #33

Closed
wants to merge 23 commits into
from

Conversation

Projects
None yet
4 participants
Owner

Garyfallidis commented Jul 1, 2012

Hi, this is my initial approach to create an class to deal with b-values and b-vectors. It would be nice to have some ways to transform the b-vectors if needed I think Matthew and Bago had some ideas about that. I wouldn't prioritise it for the time being but please be my guest.

The main idea with the class DiffusionGradients is that it has as attributes .bvals and .bvecs in an ndarray form of (N,) and (N, 3) respectively which is then easy to handle later in the reconstruction models.

Cheers,
Eleftherios

@stefanv stefanv commented on the diff Jul 1, 2012

dipy/core/gradients.py
+from os.path import splitext
+
+class DiffusionGradients(object):
+ def __init__(self, bvals, bvecs=None, b0_thr=20, atol=1e-2):
+ """ A general class for handling information about diffusion MR gradients .
+
+ This class is especially useful as an input for signal reconstruction methods.
+ It reads, loads and prepares scanner parameters like the b-values and b-vectors
+ so that they can be useful during the reconstruction process.
+
+ Parameters
+ ----------
+
+ bvals: can be any of the four options
+ 1. an array of shape (N,) or (1, N) or (N, 1) with the b-values.
+ 2. a path for the file which contains an array like the above (1).
@stefanv

stefanv Jul 1, 2012

Contributor

A .npy file?

@Garyfallidis

Garyfallidis Jul 1, 2012

Owner

Yes, a numpy array file. At least I use it some times to store bvals and bvecs (see data.get_data)

@stefanv

stefanv Jul 1, 2012

Contributor

Sure, just mention it in the docstring so the user knows what to supply.

@stefanv stefanv and 1 other commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+ are considered as b0s i.e. without diffusion weighting
+ (See notes).
+ atol: float
+ all b-vectors need to be unit vectors up to a tolerance.
+
+ Attributes
+ ----------
+ bvals: array, shape (N,)
+ b-values
+ bvecs: array, shape (N,3)
+ b-vectors
+ info: short information string
+
+ Methods
+ -------
+ expose_b0s: show which b-values are smaller or equal
@stefanv

stefanv Jul 1, 2012

Contributor

I don't think we need both of these masks, and they should probably be attributes rather than methods.

How about just mask_non_b0 or mask_signal?

@Garyfallidis

Garyfallidis Jul 1, 2012

Owner

mask_signal is not accurate as both data corresponding both to b0s and nonb0s are signal. I could rename those to non_b0s and b0s. Very happy to make them attributes too. Is there a rule for a method becoming an attribute? Perhaps when it takes no input and returns a single value?

@stefanv

stefanv Jul 2, 2012

Contributor

I think since they're going to remain constant, it makes sense for them to be properties. But either way, I don't think we need to provide both--just non_b0s should do.

@Garyfallidis

Garyfallidis Jul 2, 2012

Owner

From my experience it common to need both. Actually, I would say that most common is to ask to know where the b0s are. Maybe a better name is b0_indices and nonb0_indices. But, I strongly believe that those are both useful for understanding the data.

@stefanv

stefanv Jul 2, 2012

Contributor

Sure, but the one can simply be obtained from the other as "~b0_indices".

@Garyfallidis

Garyfallidis Jul 4, 2012

Owner

Okay this change the function to binary output. I am happy to do this.

@stefanv stefanv and 1 other commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+ transform: align the b-vectors to a different coordinate system
+
+ Examples
+ --------
+ >>> from dipy.core.gradients import DiffusionGradients
+ >>> bvals=1500*np.ones(7)
+ >>> bvals[0]=0
+ >>> sq2=np.sqrt(2)/2
+ >>> bvecs=np.array([[0, 0, 0],
+ [1, 0, 0],
+ [0, 1, 0],
+ [0, 0, 1],
+ [sq2, sq2, 0],
+ [sq2, 0, sq2],
+ [0, sq2, sq2]])
+ >>> gt = DiffusionGradients((bvals, bvecs))
@stefanv

stefanv Jul 1, 2012

Contributor

DiffusionGradients(bvals, bvecs) ?

@Garyfallidis

Garyfallidis Jul 1, 2012

Owner

Yes sorry. I will correct this shortly.

@stefanv stefanv and 1 other commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+ if self.bvecs.shape[1]>self.bvecs.shape[0]:
+ self.bvecs=self.bvecs.T
+ #check if bvecs are unit vectors
+ sqrtb=np.sqrt(self.bvecs[:,0]**2+self.bvecs[:,1]**2+self.bvecs[:,2]**2)
+ sqrtb=sqrtb[self.expose_nonb0s()]
+ if not np.allclose(sqrtb,np.ones(len(sqrtb)),atol=atol):
+ raise ValueError('B-vectors should be unit vectors')
+
+
+ def norm_q_vectors(self, b0_thr=None):
+ ''' normalized q_vectors from bvals and bvecs
+ '''
+ if b0_thr==None:
+ b0_thr=self.b0_thr
+ bv=self.bvals[self.bvals>b0_thr]
+ bmin=np.sort(bv)[1]
@stefanv

stefanv Jul 1, 2012

Contributor

What happens here? Could this be done by going xyz -> (r, theta, phi) -> (scale, theta, phi) -> xyz ?

@Garyfallidis

Garyfallidis Jul 1, 2012

Owner

Those are the q_vectors who fill the q_space.

@stefanv

stefanv Jul 2, 2012

Contributor

But I was wondering if we could improve the logic here to make it clearer to the reader. What exactly is it supposed to do?

@Garyfallidis

Garyfallidis Jul 2, 2012

Owner

I think I will remove this section entirely. Might create another class for q-space at a later stage. Otherwise I think it will be difficult to explain and connect at this point.

@stefanv stefanv and 1 other commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+
+
+ def norm_q_vectors(self, b0_thr=None):
+ ''' normalized q_vectors from bvals and bvecs
+ '''
+ if b0_thr==None:
+ b0_thr=self.b0_thr
+ bv=self.bvals[self.bvals>b0_thr]
+ bmin=np.sort(bv)[1]
+ bv=np.sqrt(bv/bmin)
+ return np.vstack((bv, bv, bv)).T*self.bvecs
+
+ def expose_b0s(self, b0_thr=None):
+ """ find where b0s are held
+ """
+ if b0_thr==None:
@stefanv

stefanv Jul 1, 2012

Contributor

if b0_thr is None

@Garyfallidis

Garyfallidis Jul 2, 2012

Owner

Cool will fix that.

@stefanv stefanv and 1 other commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+ def transform(self):
+ """ reorient gradients to a different coordinate system
+ """
+ raise NotImplementedError('Transformation of Gradients not implemented yet')
+
+ @property
+ def info(self):
+ print('B-values shape (%d,)' % self.bvals.shape)
+ print(' min %f ' % self.bvals.min())
+ print(' max %f ' % self.bvals.max())
+ print('B-vectors shape (%d, %d)' % self.bvecs.shape)
+ print(' min %f ' % self.bvecs.min())
+ print(' max %f ' % self.bvecs.max())
+
+
+def read_bvals_bvecs_files(fbvals,fbvecs):
@stefanv

stefanv Jul 1, 2012

Contributor

Does this belong in the IO module?

@Garyfallidis

Garyfallidis Jul 2, 2012

Owner

Yes, we could move it there. In io there is a bvecstxt module from Bago which I had a look at and later created those functions. So, I could put them back to io. Module name btable.py in io?

@stefanv stefanv commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+ """ reorient gradients to a different coordinate system
+ """
+ raise NotImplementedError('Transformation of Gradients not implemented yet')
+
+ @property
+ def info(self):
+ print('B-values shape (%d,)' % self.bvals.shape)
+ print(' min %f ' % self.bvals.min())
+ print(' max %f ' % self.bvals.max())
+ print('B-vectors shape (%d, %d)' % self.bvecs.shape)
+ print(' min %f ' % self.bvecs.min())
+ print(' max %f ' % self.bvecs.max())
+
+
+def read_bvals_bvecs_files(fbvals,fbvecs):
+ """ Read b-values and b-vectors from the disk
@stefanv

stefanv Jul 1, 2012

Contributor

From what type of files?

@stefanv stefanv and 1 other commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+ def info(self):
+ print('B-values shape (%d,)' % self.bvals.shape)
+ print(' min %f ' % self.bvals.min())
+ print(' max %f ' % self.bvals.max())
+ print('B-vectors shape (%d, %d)' % self.bvecs.shape)
+ print(' min %f ' % self.bvecs.min())
+ print(' max %f ' % self.bvecs.max())
+
+
+def read_bvals_bvecs_files(fbvals,fbvecs):
+ """ Read b-values and b-vectors from the disk
+
+ Parameters
+ ----------
+ fbvals: str
+ path of file with b-values
@stefanv

stefanv Jul 1, 2012

Contributor

Indentation

@Garyfallidis

Garyfallidis Jul 2, 2012

Owner

What is the exact indentation problem? Comma after str would solve that?

@stefanv

stefanv Jul 2, 2012

Contributor

The indentation should be 4 spaces.

@stefanv stefanv commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+ """ Read b-values and b-vectors from the disk
+
+ Parameters
+ ----------
+ fbvals: str
+ path of file with b-values
+ fbvecs: str
+ path of file with b-vectors
+
+ Returns
+ -------
+ bvals: array, (N,)
+ bvecs: array, (N, 3)
+
+ """
+ if isinstance(fbvals,str) and isinstance(fbvecs,str):
@stefanv

stefanv Jul 1, 2012

Contributor

Note sure if this is the right way to test for strings across python 2 and 3.

Well, I think this is fine for now. We'll probably not be dealing with unicode filenames... right? :)

@stefanv stefanv and 2 others commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
@@ -0,0 +1,228 @@
+import numpy as np
+from os.path import splitext
+
+class DiffusionGradients(object):
@stefanv

stefanv Jul 1, 2012

Contributor

why not GradientTable as originally discussed?

@Garyfallidis

Garyfallidis Jul 2, 2012

Owner

I 've been thinking and playing a lot with different names. Haven't decided the name yet. Perhaps the most accurate is to use BTable for the class name. It describes well what this function is doing. Another class could be GradientTable and that could give you back some extra parameters e.g. timing parameters like small delta and big delta. I am open to suggestions.

@Garyfallidis

Garyfallidis Jul 2, 2012

Owner

I am +1 for BTable. What others think?

@arokem

arokem Jul 2, 2012

Owner

I vote for having all of this in one class, with a name like GradientTable, or DiffusionGradients.

@stefanv stefanv and 1 other commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+ Parameters
+ ----------
+
+ bvals: can be any of the four options
+ 1. an array of shape (N,) or (1, N) or (N, 1) with the b-values.
+ 2. a path for the file which contains an array like the above (1).
+ 3. an array of shape (N, 4) or (4, N). Then this parameter is considered
+ to be a b-table which contains both bvals and bvecs. In this case
+ the next parameter is skipped.
+ 4. a path for the file which contains an array like the one at (3).
+
+ bvecs: can be any of two options
+ 1. an array of shape (N, 3) or (3, N) with the b-vectors.
+ 2. a path for the file wich contains an array like the previous.
+
+ b0_thr: float
@stefanv

stefanv Jul 1, 2012

Contributor

Write it out as b0_threshold?

@Garyfallidis

Garyfallidis Jul 1, 2012

Owner

Do you mean in the docstring but not in the parameter or both?

@stefanv

stefanv Jul 2, 2012

Contributor

I meant in both--to have it more descriptive.

@Garyfallidis

Garyfallidis Jul 2, 2012

Owner

Okay I can fix that.

@stefanv stefanv and 1 other commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+ 2. a path for the file wich contains an array like the previous.
+
+ b0_thr: float
+ all b-values with values lower than this threshold
+ are considered as b0s i.e. without diffusion weighting
+ (See notes).
+ atol: float
+ all b-vectors need to be unit vectors up to a tolerance.
+
+ Attributes
+ ----------
+ bvals: array, shape (N,)
+ b-values
+ bvecs: array, shape (N,3)
+ b-vectors
+ info: short information string
@stefanv

stefanv Jul 1, 2012

Contributor

Where does this come from? Is it used?

@Garyfallidis

Garyfallidis Jul 1, 2012

Owner

Just prints some info and low level stats. I would like some feedback from you guys about this. Do we want to give some stats out from the class?

@stefanv

stefanv Jul 2, 2012

Contributor

I don't have any experience with using gtables, so I'll leave this up to you guys.

@stefanv stefanv commented on an outdated diff Jul 1, 2012

dipy/core/gradients.py
+ if max(bvals.shape)!=max(bvecs.shape):
+ raise IOError('b-values and b-vectors shapes do not correspond')
+ else:
+ raise ValueError('Two strings with the full filepaths are required')
+
+ return bvals, bvecs
+
+def read_btable_file(fbtab):
+ """ Read b-table from the disk
+
+ B-table is a 2D array which contains b-values in the
+ first column and b-vectors in the last column.
+
+ Parameters
+ ----------
+ fbtab: str,
@stefanv

stefanv Jul 1, 2012

Contributor

extra ,

@stefanv stefanv commented on the diff Jul 1, 2012

dipy/core/tests/test_gradients.py
@@ -0,0 +1,46 @@
+import numpy as np
@stefanv

stefanv Jul 1, 2012

Contributor

Tests do not cover b0 masks.

@Garyfallidis

Garyfallidis Jul 1, 2012

Owner

Sorry, not all tests are still available. I thought it would be better to get some first feedback from you guys and then add more tests. I need to stop now had to get some sleep and get prepared for the PRNI conference tomorrow.

@stefanv

stefanv Jul 2, 2012

Contributor

No problem! Just thought I'd point it out.

Contributor

stefanv commented Jul 1, 2012

Run through pyflakes and pep8 checker.

@stefanv stefanv commented on the diff Jul 1, 2012

dipy/core/gradients.py
+ """ A general class for handling information about diffusion MR gradients .
+
+ This class is especially useful as an input for signal reconstruction methods.
+ It reads, loads and prepares scanner parameters like the b-values and b-vectors
+ so that they can be useful during the reconstruction process.
+
+ Parameters
+ ----------
+
+ bvals: can be any of the four options
+ 1. an array of shape (N,) or (1, N) or (N, 1) with the b-values.
+ 2. a path for the file which contains an array like the above (1).
+ 3. an array of shape (N, 4) or (4, N). Then this parameter is considered
+ to be a b-table which contains both bvals and bvecs. In this case
+ the next parameter is skipped.
+ 4. a path for the file which contains an array like the one at (3).
@stefanv

stefanv Jul 1, 2012

Contributor

Is it worth including this case here, or should we rather provide good I/O functions separately so that users can load in their data? (I'm asking--I have no use-case experience in this regard)

@Garyfallidis

Garyfallidis Jul 1, 2012

Owner

Not sure either. Sometimes, I find myself writing np.loadtxt way too many times for loading bvalues.

@stefanv stefanv commented on an outdated diff Jul 1, 2012

dipy/core/tests/test_gradients.py
+ gtab = np.concatenate((bvals[:,None], bvecs),axis=1)
+ gt3 = DiffusionGradients(gtab)
+ assert_array_equal(gt3.bvecs, bvecs)
+ assert_array_equal(gt3.bvals, bvals)
+ gt4 = DiffusionGradients(gtab.T)
+ assert_array_equal(gt4.bvecs, bvecs)
+ assert_array_equal(gt4.bvals, bvals)
+ gt5 = DiffusionGradients(fbvals,fbvecs)
+ assert_array_equal(gt4.bvecs, bvecs)
+ assert_array_equal(gt4.bvals, bvals)
+ fimg,fbvals,fbvecs = get_data('small_101D')
+ gt5 = DiffusionGradients(fbvals,fbvecs)
+ assert_array_equal(gt4.bvecs, bvecs)
+ assert_array_equal(gt4.bvals, bvals)
+
+
@stefanv

stefanv Jul 1, 2012

Contributor
if __name__ == "__main__":
    from numpy.testing import run_module_suite
    run_module_suite()

so that test file can be run separately

Contributor

MrBago commented Jul 3, 2012

Good work, how do you guys feel about taking the logic out of the init and using io functions to handle the different types of files. I think this is more clear and makes documenting things easier. ie we could functions like gradient_table_from_textfile, gradient_table_from_npy, gradient_table_from_dicom which would all return a GradientTables.

Contributor

stefanv commented Jul 3, 2012

That works for me.

Owner

Garyfallidis commented Jul 4, 2012

Agree to remove files from the init. However, I am suggesting Btable as a better name for the class. The reason is that GradientTable could be another class that handles more parameters e.g. timing parameters from the scanner. This is often useful for models like CHARMED, microstructure etc. The BTable then only concentrates on bvalues and bvectors which makes perfect sense. Also it is mentally connected with the gradients as you need to do
from dipy.core.gradients import BTable
Furthermore, BTable is a great name because it combines both b-values and b-vecs in a single name. So, when we talk about it we can say for example that as an input for a reconstruction model you need a Sphere and a BTable. I hope that makes sense. Please let me know if this not clear.

I am not sure how easy it would be to have a function gradient_table_from_dicom or btable_from_dicom. At the moment we have dicoms working only for Siemens scanners. Nevertheless, If you see nibabel/nicom/dicomreaders.py Matthew is actually returning both the data and the btable info.

Owner

arokem commented Jul 4, 2012

Why do you want to have the GradientTable be a separate thing?
Couldn't you have it all in one place with these additional parameters
set to None per default and defined optionally?

On Wed, Jul 4, 2012 at 6:29 AM, Eleftherios Garyfallidis
reply@reply.github.com
wrote:

Agree to remove files from the init. However, I am suggesting Btable as a better name for the class. The reason is that GradientTable could be another class that handles more parameters e.g. timing parameters from the scanner. This is often useful for models like CHARMED, microstructure etc. The BTable then only concentrates on bvalues and bvectors which makes perfect sense. Also it is mentally connected with the gradients as you need to do
from dipy.core.gradients import BTable
Furthermore, BTable is a great name because it combines both b-values and b-vecs in a single name. So, when we talk about it we can say for example that as an input for a reconstruction model you need a Sphere and a BTable. I hope that makes sense. Please let me know if this not clear.

I am not sure how easy it would be to have a function gradient_table_from_dicom or btable_from_dicom. At the moment we have dicoms working only for Siemens scanners. Nevertheless, If you see nibabel/nicom/dicomreaders.py Matthew is actually returning both the data and the btable info.


Reply to this email directly or view it on GitHub:
#33 (comment)

Contributor

MrBago commented Jul 4, 2012

I don't feel strongly about this, but my vote would be for GradientTable.
Mainly for two reasons. First, in the literature gradient table is the name
most often used used for a list of gradient directions. Second, I don't see
a reason we couldn't add the functionality you're describing to this class
at some future time. Either way we should pick a name and move on.

Bago

Owner

Garyfallidis commented Jul 4, 2012

Okay if we say that we need a class which is not only about b-values and b-vectors (which is what we currently have) and it could provide other information the about the scanner's gradients that is a different story. In that case I do prefer to use GradientTable and I will add also as initial parameters big_delta and small_delta (with default values None) so that we always remember that the GradientTable is not only about b-values. Will make the changes and post asap.

On a much different topic today I was at the PRNI conference at UCL and I was talking with Felix who discovered DiPy by himself and started using it for his own research. He said he found it very useful and that he will try to contribute with his students in the following months on higher order Tensors. Community growing... people expecting eagerly the upcoming release so that they can plug& play (in a serious fashion of course)! :-)

Contributor

stefanv commented Jul 5, 2012

That's great news!

Owner

arokem commented Jul 5, 2012

Yo Eleftherios - I am getting a lot of test errors with this:

iris:dipy (elef-gtable) $nosetests
....................................E.................EE./Users/arokem/source/dipy/dipy/reconst/dti.py:216: RuntimeWarning: invalid value encountered in double_scalars
/ (ev1_ev1 + ev2_ev2 + ev3*ev3 + all_zero))

.......EE.....EE..E................................E.........S

ERROR: Failure: ImportError (No module named bvalues)

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/core/tests/test_gradients.py", line 5, in
from dipy.core.gradients import GradientTable
File "/Users/arokem/source/dipy/dipy/core/gradients.py", line 2, in
from dipy.io.bvalues import read_bvals_bvecs_files, read_btable_file
ImportError: No module named bvalues

ERROR: Failure: ImportError (No module named bvalues)

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/io/tests/test_io_gradients.py", line 6, in
from dipy.core.gradients import GradientTable
File "/Users/arokem/source/dipy/dipy/core/gradients.py", line 2, in
from dipy.io.bvalues import read_bvals_bvecs_files, read_btable_file
ImportError: No module named bvalues

ERROR: Failure: SyntaxError (invalid syntax (dsi.py, line 208))

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/reconst/tests/test_dsi.py", line 7, in
from dipy.reconst.dsi import DiffusionSpectrumModel
File "/Users/arokem/source/dipy/dipy/reconst/dsi.py", line 208
odffit =
^
SyntaxError: invalid syntax

ERROR: Failure: SyntaxError (invalid syntax (dsi.py, line 208))

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/reconst/tests/test_eit.py", line 5, in
from dipy.reconst.eit import DiffusionNablaModel, EquatorialInversionModel
File "/Users/arokem/source/dipy/dipy/reconst/eit.py", line 6, in
from dipy.reconst.dsi import project_hemisph_bvecs
File "/Users/arokem/source/dipy/dipy/reconst/dsi.py", line 208
odffit =
^
SyntaxError: invalid syntax

ERROR: Failure: ImportError (cannot import name unique_edges)

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/reconst/tests/test_gqi.py", line 6, in
from .. import gqi as gq
File "/Users/arokem/source/dipy/dipy/reconst/gqi.py", line 5, in
from .odf import OdfModel
File "/Users/arokem/source/dipy/dipy/reconst/odf.py", line 4, in
from dipy.core.geometry import unique_edges
ImportError: cannot import name unique_edges

ERROR: Failure: ImportError (cannot import name unique_edges)

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/reconst/tests/test_odf.py", line 3, in
from ..odf import OdfFit, OdfModel, gfa
File "/Users/arokem/source/dipy/dipy/reconst/odf.py", line 4, in
from dipy.core.geometry import unique_edges
ImportError: cannot import name unique_edges

ERROR: Failure: ImportError (cannot import name unique_edges)

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/reconst/tests/test_peak_finding.py", line 6, in
from dipy.core.geometry import reduce_antipodal, unique_edges
ImportError: cannot import name unique_edges

ERROR: Failure: ImportError (cannot import name unique_edges)

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/reconst/tests/test_shm.py", line 11, in
from dipy.reconst.shm import real_sph_harm,
File "/Users/arokem/source/dipy/dipy/reconst/shm.py", line 20, in
from .odf import OdfModel
File "/Users/arokem/source/dipy/dipy/reconst/odf.py", line 4, in
from dipy.core.geometry import unique_edges
ImportError: cannot import name unique_edges

ERROR: Failure: ImportError (cannot import name unique_edges)

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/tracking/tests/test_propagation.py", line 5, in
from dipy.reconst.gqi import GeneralizedQSampling
File "/Users/arokem/source/dipy/dipy/reconst/gqi.py", line 5, in
from .odf import OdfModel
File "/Users/arokem/source/dipy/dipy/reconst/odf.py", line 4, in
from dipy.core.geometry import unique_edges
ImportError: cannot import name unique_edges


Ran 119 tests in 4.872s

FAILED (SKIP=1, errors=9)

Only one of these (the gqi one) also appears on master

Owner

Garyfallidis commented Jul 5, 2012

Okay most of the errors are from the reconstruction models. Those we will fix at a different stage. Let me fix the gradienttable errors.

Contributor

stefanv commented Jul 5, 2012

Sorry, these were caused by moving functions into dipy.core.sphere.

Fixed here: #35

Owner

arokem commented Jul 5, 2012

OK - I merged and pushed in @stefanv's fixes and rebased on top of that (here: https://github.com/arokem/dipy/tree/elef-gtable).

Still remaining are these:

iris:dipy (elef-gtable) $nosetests
....................................E.................EE./Users/arokem/source/dipy/dipy/reconst/dti.py:216: RuntimeWarning: invalid value encountered in double_scalars
/ (ev1_ev1 + ev2_ev2 + ev3*ev3 + all_zero))

.......E..........................................................E.........S

ERROR: Failure: ImportError (No module named bvalues)

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/core/tests/test_gradients.py", line 5, in
from dipy.core.gradients import GradientTable
File "/Users/arokem/source/dipy/dipy/core/gradients.py", line 2, in
from dipy.io.bvalues import read_bvals_bvecs_files, read_btable_file
ImportError: No module named bvalues

ERROR: Failure: ImportError (No module named bvalues)

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/io/tests/test_io_gradients.py", line 6, in
from dipy.core.gradients import GradientTable
File "/Users/arokem/source/dipy/dipy/core/gradients.py", line 2, in
from dipy.io.bvalues import read_bvals_bvecs_files, read_btable_file
ImportError: No module named bvalues

ERROR: Failure: SyntaxError (invalid syntax (dsi.py, line 208))

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/reconst/tests/test_dsi.py", line 7, in
from dipy.reconst.dsi import DiffusionSpectrumModel
File "/Users/arokem/source/dipy/dipy/reconst/dsi.py", line 208
odffit =
^
SyntaxError: invalid syntax

ERROR: Failure: SyntaxError (invalid syntax (dsi.py, line 208))

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/reconst/tests/test_eit.py", line 5, in
from dipy.reconst.eit import DiffusionNablaModel, EquatorialInversionModel
File "/Users/arokem/source/dipy/dipy/reconst/eit.py", line 6, in
from dipy.reconst.dsi import project_hemisph_bvecs
File "/Users/arokem/source/dipy/dipy/reconst/dsi.py", line 208
odffit =
^
SyntaxError: invalid syntax

ERROR: Failure: ImportError (cannot import name GeneralizedQSampling)

Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Users/arokem/source/dipy/dipy/tracking/tests/test_propagation.py", line 5, in
from dipy.reconst.gqi import GeneralizedQSampling
ImportError: cannot import name GeneralizedQSampling


Ran 134 tests in 26.644s

FAILED (SKIP=1, errors=5)

Owner

Garyfallidis commented Jul 5, 2012

Okay I solved the two errors concerning b-values (just pushed gtable at the origin). The ones about DSI and GQI will have to wait until Bago and Stefan give some feedback for the Shm design. When that will happen I will refactor DSI and GQI so they work with the new design and pass the tests. I think that Bago had solved the dti runtime warning at some point. So Bago can you please add your solution into the nipy/dipy branch?

Owner

arokem commented Jul 6, 2012

Hey @Garyfallidis - another git thing, please don't merge in from master into feature branches. It makes the history all messed up. Please use git rebase for this kind of thing.

Owner

Garyfallidis commented Jul 6, 2012

Okay good to know. I will spend some time understanding git rebase asap.

Owner

arokem commented Jul 6, 2012

Cool. For this branch, you can make a new branch and pull my version of it:

https://github.com/arokem/dipy/tree/elef-gtable

Which is rebased on top of master (see here:
https://github.com/nipy/dipy/network).

On Fri, Jul 6, 2012 at 12:55 PM, Eleftherios Garyfallidis
reply@reply.github.com
wrote:

Okay good to know. I will spend some time understanding git rebase asap.


Reply to this email directly or view it on GitHub:
#33 (comment)

Owner

Garyfallidis commented Jul 6, 2012

I don't plan to work with gtable branch any more. Except if they are any more problems with it. I suppose you are going to merge that elef-gtable and I will delete the gtable branch from my forked repo. Does that sounds okay?

Owner

arokem commented Jul 6, 2012

Yes. Sounds like a plan.

On Fri, Jul 6, 2012 at 1:18 PM, Eleftherios Garyfallidis
reply@reply.github.com
wrote:

I don't plan to work with gtable branch any more. Except if they are any more problems with it. I suppose you are going to merge that elef-gtable and I will delete the gtable branch from my forked repo. Does that sounds okay?


Reply to this email directly or view it on GitHub:
#33 (comment)

Owner

Garyfallidis commented Jul 6, 2012

Okay gtable deleted locally and at origin. Deletion never felt that good before ;-) Elef-gtable is on your hands now @arokem .

@arokem arokem closed this Jul 10, 2012

Owner

arokem commented Jul 10, 2012

This was superseded by #39

MarcCote pushed a commit to MarcCote/dipy that referenced this pull request Sep 15, 2015

Merge pull request #33 from MarcCote/add_vtk_matrix_utils
Added tools to convert vtkMatrix to numpy and vice versa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment