Skip to content

Commit

Permalink
fix error message and remove pydeface from default conda env
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudbore committed Jun 18, 2024
1 parent 9ae71ff commit 83ede5a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
29 changes: 21 additions & 8 deletions dcm2bids/dcm2bids_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,19 @@ def run(self):

if self.bids_validate:
try:
self.logger.info(f"Validate if {self.bids_dir} is BIDS valid.")
bids_version = run_shell_command(['bids-validator', '-v'])
self.logger.info(f"Use bids-validator version: {bids_version.decode()}")
self.logger.info(f"BIDS VALIDATION")
bids_version = run_shell_command(['bids-validator', '-v'], False)
self.logger.info(f"Use bids-validator version: {bids_version.decode()[:-1]}")
bids_report = run_shell_command(['bids-validator', self.bids_dir])
self.logger.info("Report from bids-validator")
self.logger.info(bids_report.decode())
except Exception:
self.logger.error("The bids-validator does not seem to work properly. "
self.logger.error("\033[91m"
"The bids-validator does not seem to work properly. "
"The bids-validator may not be installed on your "
"computer. Please check: "
"https://github.com/bids-standard/bids-validator.")
"https://github.com/bids-standard/bids-validator."
"\033[0m")

def move(self, acq, idList, post_op):
"""Move an acquisition to BIDS format"""
Expand Down Expand Up @@ -187,9 +190,19 @@ def move(self, acq, idList, post_op):
else:
cmd = cmd.replace('dst_file', str(dstFile))

std_out = run_shell_command(cmd.split())
self.logger.debug(std_out.decode())
continue
try:
std_out = run_shell_command(cmd.split())
self.logger.debug(f"Log from: {cmd}")
self.logger.debug(std_out.decode())
self.logger.info("")
continue
except Exception:
self.logger.error(
"\033[91m"
f"The command post_op: \"{cmd}\" "
"does not seem to work properly. "
"Check if it is installed on your "
"computer.\033[0m\n")

if ".json" in ext:
data = acq.dstSidecarData(idList)
Expand Down
7 changes: 4 additions & 3 deletions dcm2bids/dcm2niix_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ def execute(self):
self.logger.info("Temporary dicom directory removed.")

if "Warning" in output or "Error" in output:
self.logger.info(f"\n{output}")
self.logger.info("Log from dcm2niix execution")
self.logger.info(f"\033[93m{output}\033[0m")
else:
self.logger.debug(f"\n{output}")

self.logger.info("Check log file for dcm2niix output\n")
self.logger.info("Check log file for dcm2niix output\n")


else:
for dicomDir in self.dicom_dirs:
Expand Down
3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ channels:
- HCC
dependencies:
- fsl-bet2
- fsl-flirt
- pydeface
- fsl-flirt

0 comments on commit 83ede5a

Please sign in to comment.