Skip to content

Commit

Permalink
fix log and output folder for dcm2bids_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudbore committed Jul 24, 2024
1 parent 1d74109 commit 386d413
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 15 additions & 8 deletions dcm2bids/cli/dcm2bids_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from dcm2bids.utils.utils import DEFAULT
from dcm2bids.utils.tools import dcm2niix_version, check_latest
from dcm2bids.utils.logger import setup_logging
from dcm2bids.utils.args import assert_dirs_empty
from dcm2bids.version import __version__


Expand Down Expand Up @@ -59,12 +58,22 @@ def main():
"""Let's go"""
parser = _build_arg_parser()
args = parser.parse_args()
out_dir = Path(args.output_dir)
log_file = (Path(DEFAULT.output_dir)
/ DEFAULT.tmp_dir_name
/ "log"
/ f"helper_{datetime.now().strftime('%Y%m%d-%H%M%S')}.log")

out_dir = Path(args.output_dir)
if args.output_dir != parser.get_default('output_dir'):
out_dir = (Path(args.output_dir)
/ DEFAULT.tmp_dir_name
/ DEFAULT.helper_dir)

log_file = (Path(args.output_dir)
/ DEFAULT.tmp_dir_name
/ "log"
/ f"helper_{datetime.now().strftime('%Y%m%d-%H%M%S')}.log")
else:
log_file = (Path(DEFAULT.output_dir)
/ DEFAULT.tmp_dir_name
/ "log"
/ f"helper_{datetime.now().strftime('%Y%m%d-%H%M%S')}.log")
if args.nest:
if isinstance(args.nest, str):
log_file = Path(
Expand Down Expand Up @@ -94,8 +103,6 @@ def main():
check_latest("dcm2bids")
check_latest("dcm2niix")

assert_dirs_empty(parser, args, out_dir)

app = Dcm2niixGen(dicom_dirs=args.dicom_dir, bids_dir=out_dir, helper=True)

rsl = app.run(force=args.overwrite)
Expand Down
2 changes: 0 additions & 2 deletions dcm2bids/dcm2niix_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ def execute(self):
else:
self.logger.debug(f"\n{output}")
self.logger.info("Check log file for dcm2niix output\n")


else:
for dicomDir in self.dicom_dirs:
shutil.copytree(dicomDir, self.output_dir, dirs_exist_ok=True)
Expand Down

0 comments on commit 386d413

Please sign in to comment.