-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump verison, merge pull request #17 from AMYPAD/dcm2nii
- Loading branch information
Showing
4 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Convert DICOM folder to a NIfTI file | ||
Usage: | ||
dcm2nii [options] <dcmpth> | ||
Arguments: | ||
<dcmpth> : Input folder containing DICOM files [default: DirChooser] | ||
Options: | ||
--fcomment COMMENT : Prefix to add to outputs | ||
--timestamp : Whether to include a timestamp in the output filename | ||
""" | ||
import logging | ||
from pathlib import Path | ||
|
||
from niftypet import nimpa | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def run(dcmpth, fcomment="converted-from-DICOM_", timestamp=True): | ||
dcmpth = Path(dcmpth) | ||
assert dcmpth.is_dir() | ||
log.info("convert") | ||
res = nimpa.dcm2nii(dcmpth, fprefix=fcomment, timestamp=timestamp) | ||
log.debug("output file:%s", res) | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.timeout(30 * 60) # 30m | ||
def test_dcm2nii(datain): | ||
dcmpth = Path(datain['mumapDCM']) | ||
assert not list(dcmpth.glob('test_dcm2nii_*.nii*')) | ||
dcm2nii = pytest.importorskip("amypet.dcm2nii") | ||
dcm2nii.run(datain['mumapDCM'], fcomment="test_dcm2nii_") | ||
assert list(dcmpth.glob('test_dcm2nii_*.nii*')) | ||
for f in dcmpth.glob('test_dcm2nii_*.nii*'): | ||
f.unlink() |