Skip to content

Commit

Permalink
MAINT: Using .strip() with multi-character strings is misleading
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Mar 18, 2024
1 parent 9050c05 commit fc2f59d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions mriqc/workflows/anatomical/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,15 +813,24 @@ def gradient_threshold(in_file, brainmask, thresh=15.0, out_file=None, aniso=Fal


def _get_imgtype(in_file):
from pathlib import Path

return int(Path(in_file).name.rstrip(".gz").rstrip(".nii").split("_")[-1][1])
return int(_get_mod(in_file)[1])


def _get_mod(in_file):
from pathlib import Path

return Path(in_file).name.rstrip(".gz").rstrip(".nii").split("_")[-1]
in_file = Path(in_file).name
try: # Python ≥ 3.9
in_file = in_file.removeprefix(".gz")
except AttributeError: # Python < 3.9
if in_file.endswith(".gz"):
in_file = in_file[:-len(".gz")]
try: # Python ≥ 3.9
in_file = in_file.removeprefix(".nii")
except AttributeError: # Python < 3.9
if in_file.endswith(".nii"):
in_file = in_file[:-len(".nii")]
return in_file.split("_")[-1]


def _pop(inlist):
Expand Down

0 comments on commit fc2f59d

Please sign in to comment.