|
17 | 17 | import dipy.reconst.dti as dti |
18 | 18 | from amico.util import PRINT, LOG, WARNING, ERROR, get_verbose |
19 | 19 | from dicelib.ui import ProgressBar |
20 | | -from pkg_resources import get_distribution |
21 | 20 | from threadpoolctl import ThreadpoolController |
22 | 21 |
|
23 | 22 | def setup( lmax=12 ) : |
@@ -74,7 +73,8 @@ def __init__( self, study_path='.', subject='.', output_path=None ) : |
74 | 73 |
|
75 | 74 | # store all the parameters of an evaluation with AMICO |
76 | 75 | self.CONFIG = {} |
77 | | - self.set_config('version', get_distribution('dmri-amico').version) |
| 76 | + from . import __version__ as version |
| 77 | + self.set_config('version', version) |
78 | 78 | self.set_config('study_path', study_path) |
79 | 79 | self.set_config('subject', subject) |
80 | 80 | self.set_config('DATA_path', pjoin( study_path, subject )) |
@@ -312,7 +312,7 @@ def set_solver( self, **params ) : |
312 | 312 | """ |
313 | 313 | if self.model is None : |
314 | 314 | ERROR( 'Model not set; call "set_model()" method first' ) |
315 | | - |
| 315 | + |
316 | 316 | solver_params = list(inspect.signature(self.model.set_solver).parameters) |
317 | 317 | params_new = {} |
318 | 318 | for key in params.keys(): |
@@ -344,7 +344,7 @@ def generate_kernels( self, regenerate = False, lmax = 12, ndirs = 500 ) : |
344 | 344 | ERROR( 'Model not set; call "set_model()" method first' ) |
345 | 345 | if not is_valid(ndirs): |
346 | 346 | ERROR( 'Unsupported value for ndirs.\nNote: Supported values for ndirs are [1, 500 (default), 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000, 32761]' ) |
347 | | - |
| 347 | + |
348 | 348 | self.BLAS_nthreads = self.get_config('BLAS_nthreads') if self.get_config('BLAS_nthreads') > 0 else cpu_count() if self.get_config('BLAS_nthreads') == -1 else ERROR('Number of BLAS threads must be positive or -1') |
349 | 349 |
|
350 | 350 | # store some values for later use |
@@ -385,7 +385,7 @@ def load_kernels( self ) : |
385 | 385 | ERROR( 'Model not set; call "set_model()" method first' ) |
386 | 386 | if self.scheme is None : |
387 | 387 | ERROR( 'Scheme not loaded; call "load_data()" first' ) |
388 | | - |
| 388 | + |
389 | 389 | self.BLAS_nthreads = self.get_config('BLAS_nthreads') if self.get_config('BLAS_nthreads') > 0 else cpu_count() if self.get_config('BLAS_nthreads') == -1 else ERROR('Number of BLAS threads must be positive or -1') |
390 | 390 |
|
391 | 391 | tic = time.time() |
@@ -418,7 +418,7 @@ def fit( self ) : |
418 | 418 | ERROR( 'Response functions were not created with the same model' ) |
419 | 419 | if self.get_config('DTI_fit_method') not in ['OLS', 'LS', 'WLS', 'NLLS', 'RT', 'RESTORE', 'restore']: |
420 | 420 | ERROR("DTI fit method must be one of the following:\n'OLS'(default) or 'LS': ordinary least squares\n'WLS': weighted least squares\n'NLLS': non-linear least squares\n'RT' or 'RESTORE' or 'restore': robust tensor\nNOTE: more info at https://dipy.org/documentation/1.6.0./reference/dipy.reconst/#dipy.reconst.dti.TensorModel") |
421 | | - |
| 421 | + |
422 | 422 | self.nthreads = self.get_config('nthreads') if self.get_config('nthreads') > 0 else cpu_count() if self.get_config('nthreads') == -1 else ERROR('Number of parallel threads must be positive or -1') |
423 | 423 | self.BLAS_nthreads = self.get_config('BLAS_nthreads') if self.get_config('BLAS_nthreads') > 0 else cpu_count() if self.get_config('BLAS_nthreads') == -1 else ERROR('Number of BLAS threads must be positive or -1') |
424 | 424 |
|
|
0 commit comments