2022-04-08T11:17:03,033 Created temporary directory: /tmp/pip-ephem-wheel-cache-1zjeygir 2022-04-08T11:17:03,039 Created temporary directory: /tmp/pip-req-tracker-e91tgbpl 2022-04-08T11:17:03,039 Initialized build tracking at /tmp/pip-req-tracker-e91tgbpl 2022-04-08T11:17:03,040 Created build tracker: /tmp/pip-req-tracker-e91tgbpl 2022-04-08T11:17:03,040 Entered build tracker: /tmp/pip-req-tracker-e91tgbpl 2022-04-08T11:17:03,041 Created temporary directory: /tmp/pip-wheel-uey795yl 2022-04-08T11:17:03,108 Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple 2022-04-08T11:17:03,116 2 location(s) to search for versions of mdreg: 2022-04-08T11:17:03,116 * https://pypi.org/simple/mdreg/ 2022-04-08T11:17:03,116 * https://www.piwheels.org/simple/mdreg/ 2022-04-08T11:17:03,117 Fetching project page and analyzing links: https://pypi.org/simple/mdreg/ 2022-04-08T11:17:03,118 Getting page https://pypi.org/simple/mdreg/ 2022-04-08T11:17:03,122 Found index url https://pypi.org/simple 2022-04-08T11:17:03,242 Skipping link: No binaries permitted for mdreg: https://files.pythonhosted.org/packages/bc/10/c83070f17306c03d644c7c76d8859872032edc1fc0df2a97380d4e93d708/mdreg-0.3.0-py3-none-any.whl#sha256=76d01b7c8b72d51decaaa5d64f040e8eb72037e15e17105cf8d1a84546559e46 (from https://pypi.org/simple/mdreg/) (requires-python:>=3.6, <4) 2022-04-08T11:17:03,244 Found link https://files.pythonhosted.org/packages/78/c8/ba73412c97b1eedd387919d54687fb19b22173a3ba98a9a77136320259eb/mdreg-0.3.0.tar.gz#sha256=7dc7854f0140d370e408b03eed00b9a8be51b382bd5ee60a10aea58706a2206b (from https://pypi.org/simple/mdreg/) (requires-python:>=3.6, <4), version: 0.3.0 2022-04-08T11:17:03,245 Skipping link: No binaries permitted for mdreg: https://files.pythonhosted.org/packages/6b/67/cd996be7b682acd1e126cc4e01f6f267fbfff5a7e5fca5c51e065c7b4497/mdreg-0.3.1-py3-none-any.whl#sha256=e3582f07ac52f4ad5b334091e8e595b32bcfb8c67c7e456920bb82eea4ba5ad4 (from https://pypi.org/simple/mdreg/) (requires-python:>=3.6, <4) 2022-04-08T11:17:03,246 Found link https://files.pythonhosted.org/packages/eb/8b/0358e3454beda70f4259a4d86932f6e072225039955f5a20d39144173ede/mdreg-0.3.1.tar.gz#sha256=8f5b490139cbe17e3c0bc07922cd8dbe529740485daf98ed0e594715236837e9 (from https://pypi.org/simple/mdreg/) (requires-python:>=3.6, <4), version: 0.3.1 2022-04-08T11:17:03,247 Fetching project page and analyzing links: https://www.piwheels.org/simple/mdreg/ 2022-04-08T11:17:03,248 Getting page https://www.piwheels.org/simple/mdreg/ 2022-04-08T11:17:03,250 Found index url https://www.piwheels.org/simple 2022-04-08T11:17:03,455 Skipping link: not a file: https://www.piwheels.org/simple/mdreg/ 2022-04-08T11:17:03,456 Skipping link: not a file: https://pypi.org/simple/mdreg/ 2022-04-08T11:17:03,500 Given no hashes to check 1 links for project 'mdreg': discarding no candidates 2022-04-08T11:17:03,541 Collecting mdreg==0.3.1 2022-04-08T11:17:03,545 Created temporary directory: /tmp/pip-unpack-n_lmx6pt 2022-04-08T11:17:03,634 Downloading mdreg-0.3.1.tar.gz (21 kB) 2022-04-08T11:17:03,762 Added mdreg==0.3.1 from https://files.pythonhosted.org/packages/eb/8b/0358e3454beda70f4259a4d86932f6e072225039955f5a20d39144173ede/mdreg-0.3.1.tar.gz#sha256=8f5b490139cbe17e3c0bc07922cd8dbe529740485daf98ed0e594715236837e9 to build tracker '/tmp/pip-req-tracker-e91tgbpl' 2022-04-08T11:17:03,763 Running setup.py (path:/tmp/pip-wheel-uey795yl/mdreg_94c330699d514040a183972b44121a53/setup.py) egg_info for package mdreg 2022-04-08T11:17:03,764 Created temporary directory: /tmp/pip-pip-egg-info-yj4rbeek 2022-04-08T11:17:03,765 Preparing metadata (setup.py): started 2022-04-08T11:17:03,767 Running command python setup.py egg_info 2022-04-08T11:17:05,320 Traceback (most recent call last): 2022-04-08T11:17:05,322 File "", line 2, in 2022-04-08T11:17:05,323 File "", line 34, in 2022-04-08T11:17:05,325 File "/tmp/pip-wheel-uey795yl/mdreg_94c330699d514040a183972b44121a53/setup.py", line 13, in 2022-04-08T11:17:05,326 with open('requirements.txt', encoding='utf-8') as f: 2022-04-08T11:17:05,327 FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt' 2022-04-08T11:17:05,328 # Description 2022-04-08T11:17:05,328 Python implementation of model-based image coregistration 2022-04-08T11:17:05,329 for quantitative medical imaging applications. 2022-04-08T11:17:05,329 The distribution comes with a number of common signal models and uses [ITK-Elastix](https://github.com/InsightSoftwareConsortium/ITKElastix) for deformable image registration. 2022-04-08T11:17:05,330 ## Installation 2022-04-08T11:17:05,330 Run `pip install mdreg`. 2022-04-08T11:17:05,331 ## Example data 2022-04-08T11:17:05,331 Example data in [DICOM format](https://shorturl.at/rwCUV) are provided for testing the setup. 2022-04-08T11:17:05,332 ## How to use 2022-04-08T11:17:05,332 Input data must be image arrays in numpy format, with dimensions `(x,y,z,t)` or `(x,y,t)`. 2022-04-08T11:17:05,333 To perform MDR on an image array `im` with default settings do: 2022-04-08T11:17:05,334 ```python 2022-04-08T11:17:05,334 from mdreg import MDReg 2022-04-08T11:17:05,335 mdr = MDReg() 2022-04-08T11:17:05,336 mdr.set_array(im) 2022-04-08T11:17:05,336 mdr.fit() 2022-04-08T11:17:05,337 ``` 2022-04-08T11:17:05,337 When fitting is complete the motion-corrected data are in `mdr.coreg` in the same dimensions 2022-04-08T11:17:05,338 as the original `im`. The calculated deformation fields in format `(x,y,d,t)` or `(x,y,z,d,t)` 2022-04-08T11:17:05,338 can be found as `mdr.deformation`. The dimension `d` holds `x`, `y` components 2022-04-08T11:17:05,339 of the deformation field, and a third `z` component if the input array is 3D. 2022-04-08T11:17:05,339 The default settings will apply a linear signal model and coregistration 2022-04-08T11:17:05,340 as defined in the elastix parameter file `Bsplines.txt`. 2022-04-08T11:17:05,341 # Customization 2022-04-08T11:17:05,342 MDR can be configured to apply different signal models and elastix coregistration settings. 2022-04-08T11:17:05,342 A number of example models and alternative elastix parameter files are included 2022-04-08T11:17:05,342 in the distribution as templates. 2022-04-08T11:17:05,343 The following example fits a mono-exponential decay, uses a mask `im_mask` for co-registration and applies an elastix parameter file `par_file` optimized for a previous DTI-MRI study: 2022-04-08T11:17:05,344 ```python 2022-04-08T11:17:05,344 from mdreg import MDReg 2022-04-08T11:17:05,345 from mdreg.models import exponential_decay 2022-04-08T11:17:05,346 mdr = MDReg() 2022-04-08T11:17:05,346 mdr.set_array(im) 2022-04-08T11:17:05,347 mdr.set_mask(im_mask) 2022-04-08T11:17:05,347 mdr.signal_model = exponential_decay 2022-04-08T11:17:05,347 mdr.read_elastix(par_file) 2022-04-08T11:17:05,348 mdr.fit() 2022-04-08T11:17:05,348 ``` 2022-04-08T11:17:05,349 `im_mask` must be a binary (0s and 1s) or boolean (Trues and Falses) image array in numpy format with the same dimensions as `im`. 2022-04-08T11:17:05,350 The signal model often depends on fixed constants and signal parameters 2022-04-08T11:17:05,350 such as sequence parameters in MRI, or patient-specific constants. These 2022-04-08T11:17:05,351 should all be grouped in a list and set before running the signal model. 2022-04-08T11:17:05,352 Equally elastix parameters can be fine tuned, either by importing a 2022-04-08T11:17:05,352 dedicated elastix file, or by modifying the settings. 2022-04-08T11:17:05,353 You may also choose if you wish to run the process in multiple cores (`parallel`) and to print the co-registration progress to the terminal plus a text file (`log`) or not. 2022-04-08T11:17:05,354 Then, a number of parameters are available to optimize MDR such as 2022-04-08T11:17:05,354 the precision (stopping criterion) and maximum number of iterations. 2022-04-08T11:17:05,355 Some examples: 2022-04-08T11:17:05,356 ```python 2022-04-08T11:17:05,357 from mdreg import MDReg 2022-04-08T11:17:05,357 from mdreg.models import exponential_decay 2022-04-08T11:17:05,358 t = [0.0, 1.25, 2.50, 3.75] # time points for exponential in sec 2022-04-08T11:17:05,359 mdr = MDReg() 2022-04-08T11:17:05,359 mdr.set_array(im) 2022-04-08T11:17:05,360 mdr.signal_parameters = t 2022-04-08T11:17:05,360 mdr.signal_model = exponential_decay 2022-04-08T11:17:05,360 mdr.set_elastix(MaximumNumberOfIterations = 256) # change defaults 2022-04-08T11:17:05,361 mdr.precision = 0.5 # default = 1 2022-04-08T11:17:05,361 mdr.max_iterations = 3 # default = 5 2022-04-08T11:17:05,362 mdr.parallel = False # default = True 2022-04-08T11:17:05,362 mdr.log = True # default = False 2022-04-08T11:17:05,363 mdr.fit() 2022-04-08T11:17:05,363 ``` 2022-04-08T11:17:05,364 `mdreg` comes with a number of options to 2022-04-08T11:17:05,364 export results and diagnostics: 2022-04-08T11:17:05,365 ```python 2022-04-08T11:17:05,366 mdr.export_unregistered = True # export parameters and fit without registration 2022-04-08T11:17:05,366 mdr.export_path = filepath # default is a results folder in the current working directory 2022-04-08T11:17:05,367 mdr.export() # export results after calling fit. 2022-04-08T11:17:05,367 ``` 2022-04-08T11:17:05,368 This export creates movies of original images, motion corrected images, 2022-04-08T11:17:05,368 modelfits, and maps of the fitted parameters. 2022-04-08T11:17:05,369 # Model fitting without motion correction 2022-04-08T11:17:05,370 `MDReg` also can be used to perform model fitting 2022-04-08T11:17:05,370 without correcting the motion. The following script 2022-04-08T11:17:05,371 fits a linearised exponential model to each pixel and exports data 2022-04-08T11:17:05,371 of model and fit: 2022-04-08T11:17:05,372 ```python 2022-04-08T11:17:05,372 from mdreg import MDReg 2022-04-08T11:17:05,373 from mdreg.models import exponential_decay 2022-04-08T11:17:05,374 mdr = MDReg() 2022-04-08T11:17:05,374 mdr.set_array(im) 2022-04-08T11:17:05,375 mdr.signal_model = linear_exponential_decay 2022-04-08T11:17:05,375 mdr.fit_signal() 2022-04-08T11:17:05,376 mdr.export_data() 2022-04-08T11:17:05,376 mdr.export_fit() 2022-04-08T11:17:05,377 ``` 2022-04-08T11:17:05,377 # Defining new MDR models 2022-04-08T11:17:05,378 A model must be defined as a separate module or class with two required functions `main()` and `pars()`. 2022-04-08T11:17:05,379 `pars()` must return a list of strings specifying the names of the model parameters. 2022-04-08T11:17:05,379 `main(im, const)` performs the pixel based model fitting and has two required arguments. 2022-04-08T11:17:05,380 `im` is a numpy ndarray with dimensions `(x,y,z,t)`, `(x,y,t)` or `(x,t)`. `const` is a list 2022-04-08T11:17:05,380 of any constant model parameters. 2022-04-08T11:17:05,381 The function must return the fit to the model as an numpy ndarray with the same dimensions 2022-04-08T11:17:05,381 as `im`, and an ndarray `pars` with dimensions `(x,y,z,p)`, `(x,y,p)` or `(x,p)`. Here `p` enumerates 2022-04-08T11:17:05,382 the model parameters. 2022-04-08T11:17:05,383 ## Context 2022-04-08T11:17:05,383 `mdreg` was first developed for use in quantitative renal MRI in the iBEAt study, 2022-04-08T11:17:05,384 and validated against group-wise model-free registration 2022-04-08T11:17:05,384 (Tagkalakis F, et al. Model-based motion correction outperforms a model-free method in quantitative renal MRI. Abstract-1383, ISMRM 2021). 2022-04-08T11:17:05,385 ## Acknowledgement 2022-04-08T11:17:05,386 The iBEAt study is part of the BEAt-DKD project. The BEAt-DKD project has received funding from the Innovative Medicines Initiative 2 Joint Undertaking under grant agreement No 115974. This Joint Undertaking receives support from the European Union’s Horizon 2020 research and innovation programme and EFPIA with JDRF. For a full list of BEAt-DKD partners, see www.beat-dkd.eu. 2022-04-08T11:17:05,387 ## Authors 2022-04-08T11:17:05,388 Kanishka Sharma, Joao Almeida e Sousa, Steven Sourbron 2022-04-08T11:17:05,434 ERROR: [present-diagnostic] python setup.py egg_info exited with 1 2022-04-08T11:17:05,474 [bold magenta]full command[/]: [blue]/usr/bin/python3 -c ' 2022-04-08T11:17:05,474 exec(compile('"'"''"'"''"'"' 2022-04-08T11:17:05,474 # This is -- a caller that pip uses to run setup.py 2022-04-08T11:17:05,474 # 2022-04-08T11:17:05,474 # - It imports setuptools before invoking setup.py, to enable projects that directly 2022-04-08T11:17:05,474 # import from `distutils.core` to work with newer packaging standards. 2022-04-08T11:17:05,474 # - It provides a clear error message when setuptools is not installed. 2022-04-08T11:17:05,474 # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so 2022-04-08T11:17:05,474 # setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning: 2022-04-08T11:17:05,474 # manifest_maker: standard file '"'"'-c'"'"' not found". 2022-04-08T11:17:05,474 # - It generates a shim setup.py, for handling setup.cfg-only projects. 2022-04-08T11:17:05,474 import os, sys, tokenize 2022-04-08T11:17:05,474 2022-04-08T11:17:05,474 try: 2022-04-08T11:17:05,474 import setuptools 2022-04-08T11:17:05,474 except ImportError as error: 2022-04-08T11:17:05,474 print( 2022-04-08T11:17:05,474 "ERROR: Can not execute `setup.py` since setuptools is not available in " 2022-04-08T11:17:05,474 "the build environment.", 2022-04-08T11:17:05,474 file=sys.stderr, 2022-04-08T11:17:05,474 ) 2022-04-08T11:17:05,474 sys.exit(1) 2022-04-08T11:17:05,474 2022-04-08T11:17:05,474 __file__ = %r 2022-04-08T11:17:05,474 sys.argv[0] = __file__ 2022-04-08T11:17:05,474 2022-04-08T11:17:05,474 if os.path.exists(__file__): 2022-04-08T11:17:05,474 filename = __file__ 2022-04-08T11:17:05,474 with tokenize.open(__file__) as f: 2022-04-08T11:17:05,474 setup_py_code = f.read() 2022-04-08T11:17:05,474 else: 2022-04-08T11:17:05,474 filename = "" 2022-04-08T11:17:05,474 setup_py_code = "from setuptools import setup; setup()" 2022-04-08T11:17:05,474 2022-04-08T11:17:05,474 exec(compile(setup_py_code, filename, "exec")) 2022-04-08T11:17:05,474 '"'"''"'"''"'"' % ('"'"'/tmp/pip-wheel-uey795yl/mdreg_94c330699d514040a183972b44121a53/setup.py'"'"',), "", "exec"))' egg_info --egg-base /tmp/pip-pip-egg-info-yj4rbeek[/] 2022-04-08T11:17:05,474 [bold magenta]cwd[/]: /tmp/pip-wheel-uey795yl/mdreg_94c330699d514040a183972b44121a53/ 2022-04-08T11:17:05,475 Preparing metadata (setup.py): finished with status 'error' 2022-04-08T11:17:05,477 ERROR: [present-diagnostic] metadata generation failed 2022-04-08T11:17:05,491 Exception information: 2022-04-08T11:17:05,491 Traceback (most recent call last): 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/operations/build/metadata_legacy.py", line 64, in generate_metadata 2022-04-08T11:17:05,491 call_subprocess( 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/utils/subprocess.py", line 224, in call_subprocess 2022-04-08T11:17:05,491 raise error 2022-04-08T11:17:05,491 pip._internal.exceptions.InstallationSubprocessError: python setup.py egg_info exited with 1 2022-04-08T11:17:05,491 2022-04-08T11:17:05,491 The above exception was the direct cause of the following exception: 2022-04-08T11:17:05,491 2022-04-08T11:17:05,491 Traceback (most recent call last): 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper 2022-04-08T11:17:05,491 status = run_func(*args) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/cli/req_command.py", line 205, in wrapper 2022-04-08T11:17:05,491 return func(self, options, args) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/commands/wheel.py", line 145, in run 2022-04-08T11:17:05,491 requirement_set = resolver.resolve(reqs, check_supported_wheels=True) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/resolution/resolvelib/resolver.py", line 94, in resolve 2022-04-08T11:17:05,491 result = self._result = resolver.resolve( 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve 2022-04-08T11:17:05,491 state = resolution.resolve(requirements, max_rounds=max_rounds) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 348, in resolve 2022-04-08T11:17:05,491 self._add_to_criteria(self.state.criteria, r, parent=None) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria 2022-04-08T11:17:05,491 if not criterion.candidates: 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__ 2022-04-08T11:17:05,491 return bool(self._sequence) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__ 2022-04-08T11:17:05,491 return any(self) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in 2022-04-08T11:17:05,491 return (c for c in iterator if id(c) not in self._incompatible_ids) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47, in _iter_built 2022-04-08T11:17:05,491 candidate = func() 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/resolution/resolvelib/factory.py", line 215, in _make_candidate_from_link 2022-04-08T11:17:05,491 self._link_candidate_cache[link] = LinkCandidate( 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 288, in __init__ 2022-04-08T11:17:05,491 super().__init__( 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 158, in __init__ 2022-04-08T11:17:05,491 self.dist = self._prepare() 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 227, in _prepare 2022-04-08T11:17:05,491 dist = self._prepare_distribution() 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 299, in _prepare_distribution 2022-04-08T11:17:05,491 return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/operations/prepare.py", line 487, in prepare_linked_requirement 2022-04-08T11:17:05,491 return self._prepare_linked_requirement(req, parallel_builds) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/operations/prepare.py", line 556, in _prepare_linked_requirement 2022-04-08T11:17:05,491 dist = _get_prepared_distribution( 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/operations/prepare.py", line 58, in _get_prepared_distribution 2022-04-08T11:17:05,491 abstract_dist.prepare_distribution_metadata(finder, build_isolation) 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/distributions/sdist.py", line 47, in prepare_distribution_metadata 2022-04-08T11:17:05,491 self.req.prepare_metadata() 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/req/req_install.py", line 528, in prepare_metadata 2022-04-08T11:17:05,491 self.metadata_directory = generate_metadata_legacy( 2022-04-08T11:17:05,491 File "/usr/local/lib/python3.9/dist-packages/pip/_internal/operations/build/metadata_legacy.py", line 71, in generate_metadata 2022-04-08T11:17:05,491 raise MetadataGenerationFailed(package_details=details) from error 2022-04-08T11:17:05,491 pip._internal.exceptions.MetadataGenerationFailed: metadata generation failed 2022-04-08T11:17:05,514 Removed mdreg==0.3.1 from https://files.pythonhosted.org/packages/eb/8b/0358e3454beda70f4259a4d86932f6e072225039955f5a20d39144173ede/mdreg-0.3.1.tar.gz#sha256=8f5b490139cbe17e3c0bc07922cd8dbe529740485daf98ed0e594715236837e9 from build tracker '/tmp/pip-req-tracker-e91tgbpl' 2022-04-08T11:17:05,515 Removed build tracker: '/tmp/pip-req-tracker-e91tgbpl'