Skip to content

Module dcm2bids.helper⚓︎

helper module

None

View Source
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# -*- coding: utf-8 -*-

"""helper module"""

import argparse

import os

from pathlib import Path

import sys

from dcm2bids.dcm2niix import Dcm2niix

from dcm2bids.utils import DEFAULT, assert_dirs_empty

def _build_arg_parser():

    p = argparse.ArgumentParser(description=__doc__, epilog=DEFAULT.EPILOG,

                                formatter_class=argparse.RawTextHelpFormatter)

    p.add_argument("-d", "--dicom_dir",

                   type=Path,

                   required=True, nargs="+",

                   help="DICOM files directory.")

    p.add_argument("-o", "--output_dir",

                   required=False, default=Path.cwd(),

                   type=Path,

                   help="Output BIDS directory. "

                        "(Default: %(default)s)")

    p.add_argument('--force',

                   dest='overwrite', action='store_true',

                   help='Force command to overwrite existing output files.')

    return p

def main():

    """Let's go"""

    parser = _build_arg_parser()

    args = parser.parse_args()

    out_folder = args.output_dir / DEFAULT.tmpDirName / DEFAULT.helperDir

    assert_dirs_empty(parser, args, out_folder)

    app = Dcm2niix(dicomDirs=args.dicom_dir, bidsDir=args.output_dir)

    rsl = app.run()

    print(f"Example in: {out_folder}")

    return rsl

if __name__ == "__main__":

    sys.exit(main())

Functions⚓︎

main⚓︎

1
2
3
def main(

)

Let's go

View Source
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def main():

    """Let's go"""

    parser = _build_arg_parser()

    args = parser.parse_args()

    out_folder = args.output_dir / DEFAULT.tmpDirName / DEFAULT.helperDir

    assert_dirs_empty(parser, args, out_folder)

    app = Dcm2niix(dicomDirs=args.dicom_dir, bidsDir=args.output_dir)

    rsl = app.run()

    print(f"Example in: {out_folder}")

    return rsl

Last update: 2022-06-17
Back to top