Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiP(idea): memoize get_study_sessions result #571

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions heudiconv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def process_extra_commands(outdir, command, files, dicom_dir_template,
heuristic_ls = getattr(heuristic, 'ls', None)
for f in files:
study_sessions = get_study_sessions(
dicom_dir_template, [f], heuristic, outdir,
[f], dicom_dir_template, heuristic, outdir,
session, subjs, grouping=grouping)
print(f)
for study_session, sequences in study_sessions.items():
Expand Down Expand Up @@ -324,7 +324,7 @@ def workflow(*, dicom_dir_template=None, files=None, subjs=None,

heuristic = load_heuristic(heuristic)

study_sessions = get_study_sessions(dicom_dir_template, files,
study_sessions = get_study_sessions(files, dicom_dir_template,
heuristic, outdir, session,
subjs, grouping=grouping)

Expand Down
12 changes: 11 additions & 1 deletion heudiconv/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,18 @@ def get_extracted_dicoms(fl):

return sessions.items()

from fscacher import PersistentCache
from ._version import __version__

def get_study_sessions(dicom_dir_template, files_opt, heuristic, outdir,
study_sessions_cache = PersistentCache(
name="heudiconv-study-sessions",
tokens=[__version__],
envvar="HEUDICONV_CACHE",
)


@study_sessions_cache.memoize_paths
def get_study_sessions(files_opt, dicom_dir_template, heuristic, outdir,
session, sids, grouping='studyUID'):
"""Given options from cmdline sort files or dicom seqinfos into
study_sessions which put together files for a single session of a subject
Expand Down