Skip to content

Commit 152a9a8

Browse files
authored
bump verison, merge pull request #17 from AMYPAD/dcm2nii
2 parents a408348 + 3da8ac7 commit 152a9a8

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ Amyloid imaging to prevent Alzheimer's Disease.
99
Install
1010
-------
1111

12-
Choose one of the following:
12+
Requires Python 3.6 or greater. Choose one of the following:
1313

1414
.. code:: sh
1515
16-
pip install amypet # command line interface (CLI) version
16+
pip install amypet # command line interface (CLI) version
1717
pip install amypet[gui] # CLI and graphical user interface (GUI) version
1818
19+
For certain functionality (image trimming & resampling, DICOM to NIfTI converters) it may be required to also `pip install nimpa`.
20+
1921

2022
Usage
2123
-----

amypet/dcm2nii.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Convert DICOM folder to a NIfTI file
2+
3+
Usage:
4+
dcm2nii [options] <dcmpth>
5+
6+
Arguments:
7+
<dcmpth> : Input folder containing DICOM files [default: DirChooser]
8+
9+
Options:
10+
--fcomment COMMENT : Prefix to add to outputs
11+
--timestamp : Whether to include a timestamp in the output filename
12+
"""
13+
import logging
14+
from pathlib import Path
15+
16+
from niftypet import nimpa
17+
18+
log = logging.getLogger(__name__)
19+
20+
21+
def run(dcmpth, fcomment="converted-from-DICOM_", timestamp=True):
22+
dcmpth = Path(dcmpth)
23+
assert dcmpth.is_dir()
24+
log.info("convert")
25+
res = nimpa.dcm2nii(dcmpth, fprefix=fcomment, timestamp=timestamp)
26+
log.debug("output file:%s", res)
27+
return res

amypet/gui.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def main(args=None, gui_mode=True):
249249
import niftypad.api
250250
import niftypad.models
251251

252-
from amypet import centiloid, imscroll, imtrimup
252+
from amypet import centiloid, dcm2nii, imscroll, imtrimup
253253

254254
parser = fix_subparser(MyParser(prog=None if gui_mode else "amypet"), gui_mode=gui_mode)
255255
sub_kwargs = {}
@@ -273,6 +273,9 @@ def argparser(prog, description=None, epilog=None, formatter_class=None):
273273
Func(imscroll.run, imscroll.__doc__, version=niftypad.__version__,
274274
python_deps=["miutil[nii,plot]", "tqdm"], argparser=argparser)
275275

276+
Func(dcm2nii.run, dcm2nii.__doc__, version=niftypad.__version__, python_deps=["nimpa"],
277+
argparser=argparser)
278+
276279
Func(imtrimup.run, imtrimup.__doc__, version=niftypad.__version__, python_deps=["nimpa"],
277280
argparser=argparser)
278281

tests/test_dcm2nii.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
6+
@pytest.mark.timeout(30 * 60) # 30m
7+
def test_dcm2nii(datain):
8+
dcmpth = Path(datain['mumapDCM'])
9+
assert not list(dcmpth.glob('test_dcm2nii_*.nii*'))
10+
dcm2nii = pytest.importorskip("amypet.dcm2nii")
11+
dcm2nii.run(datain['mumapDCM'], fcomment="test_dcm2nii_")
12+
assert list(dcmpth.glob('test_dcm2nii_*.nii*'))
13+
for f in dcmpth.glob('test_dcm2nii_*.nii*'):
14+
f.unlink()

0 commit comments

Comments
 (0)