Skip to content

Commit

Permalink
More work.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Jan 24, 2024
1 parent f975bbe commit 2358c51
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
24 changes: 15 additions & 9 deletions cubids/cubids.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,20 +460,17 @@ def change_filename(self, filepath, entities):
Parameters
----------
filepath : str
Path prefix to a file in the affected key group change
entities : dictionary
A pybids dictionary of entities parsed from the new key
group name.
filepath : :obj:`str`
Path prefix to a file in the affected key group change.
entities : :obj:`dict`
A pybids dictionary of entities parsed from the new key group name.
Notes
-----
This is the function I need to spend the most time on, since it has entities hardcoded.
"""
exts = Path(filepath).suffixes
old_ext = ""
for ext in exts:
old_ext += ext
old_ext = "".join(exts)

suffix = entities["suffix"]
entity_file_keys = []
Expand Down Expand Up @@ -514,6 +511,7 @@ def change_filename(self, filepath, entities):
print("WARNING: DATATYPE CHANGE DETECETD")
else:
dtype = old

new_path = str(self.path) + "/" + sub + "/" + ses + "/" + dtype + "/" + filename

# add the scan path + new path to the lists of old, new filenames
Expand Down Expand Up @@ -825,7 +823,15 @@ def _purge_associations(self, scans):
print("Not running any association removals")

def get_nifti_associations(self, nifti):
"""Get nifti associations."""
"""Get nifti associations.
This uses globbing to find files with the same path and entities as the NIfTI,
but with a different extension and a suffix that at least starts with the same
suffix as the NIfTI.
For example, for *_asl.nii.gz, this will grab *_asl.json, *_aslcontext.tsv,
and *_asllabeling.jpg.
"""
# get all assocation files of a nifti image
no_ext_file = str(nifti).split("/")[-1].split(".")[0]
associations = []
Expand Down
17 changes: 8 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ classifiers = [
license = {file = "LICENSE"}
requires-python = ">=3.8"
dependencies = [
"pyyaml",
"pybids",
"pandas",
"tqdm",
"datalad>=0.13.5,!=0.17.3,!=0.17.0,!=0.16.1",
"jinja2 < 3.1",
"numpy",
"pandas",
"pybids",
"pyyaml",
"scikit-learn",
"datalad>=0.13.5,!=0.17.3,!=0.17.0,!=0.16.1",
"tqdm",
"wrapt<2,>=1.10",
"Sphinx",
"jinja2 < 3.1",
]
dynamic = ["version"]

Expand All @@ -44,11 +43,11 @@ Paper = "https://doi.org/10.1016/j.neuroimage.2022.119609"
doc = [
"nbsphinx",
"packaging",
"recommonmark",
"sphinx >= 2.2",
"sphinx-argparse",
"sphinx_rtd_theme",
"sphinx_markdown_tables",
"recommonmark",
"sphinx_rtd_theme",
]
tests = [
"codespell",
Expand Down

0 comments on commit 2358c51

Please sign in to comment.