PennLINC / fw-heudiconv

Heuristic-based Data Curation on Flywheel
BSD 3-Clause "New" or "Revised" License
6 stars 11 forks source link

Heudiconv "positional argument: 'time'" error #97

Closed nickwell13 closed 2 years ago

nickwell13 commented 2 years ago

Describe the issue A clear and concise description of what the challenge is.

Received error: TypeError: SeqInfo.new() missing 1 required positional argument: 'time'. This occurred when attempting heudiconv-curate and heudiconv-tabulate from the cli. I was told to downgrade my heudiconv version but this did not help.

Were you running fw-heudiconv locally or from Flywheel's GUI?

If you ran it locally, please describe your setup:

Mac OS Catalina through CLI.

Tried this with 0.8, then downgraded until 0.4 and the issue persisted.

Please paste your heuristic below:

import os

################################################################################# #################### Create keys for each acquisition type #################### #################################################################################

def create_key(template, outtype=('nii.gz',), annotation_classes=None): if template is None or not template: raise ValueError('Template must be a valid format string') return template, outtype, annotation_classes

anat

t1w = create_key( 'sub-{subject}/ses-{session}/anat/sub-{subject}_ses-{session}_T1w') t1w_ND = create_key( 'sub-{subject}/ses-{session}/anat/sub-{subject}_ses-{session}_T1w_SC')

dwi

dwi = create_key( 'sub-{subject}/ses-{session}/dwi/sub-{subject}_ses-{session}_dwi')

fmap

b0_phase1 = createkey( 'sub-{subject}/{session}/fmap/sub-{subject}{session}_phase1') b0_phase2 = createkey( 'sub-{subject}/{session}/fmap/sub-{subject}{session}_phase2')

b0_mag = create_key(

'sub-{subject}/{session}/fmap/sub-{subject}_{session}_magnitude{item}')

b0_mag1 = createkey( 'sub-{subject}/{session}/fmap/sub-{subject}{session}_magnitude1') b0_mag2 = createkey( 'sub-{subject}/{session}/fmap/sub-{subject}{session}_magnitude2')

################################################################################# ########### Define rules to map scans to the correct BIDS filename ############ #################################################################################

Institution name: PENN - HUP; NEUM - MPI for Human Development; UTMB - UTMB 3T SKYRA

def infotodict(seqinfo): """Heuristic evaluator for determining which runs belong where allowed template fields - follow python string module: item: index within category subject: participant id seqitem: run number during scanning subindex: sub index within group """

info = {t1w: [], t1w_SC: [],
    dwi: [],
    #gre: [], gre_e1: [], gre_e2: [], gre_e2_ph: [],
    b0_phase1: [], b0_phase2: [], b0_mag1: [], b0_mag2: [],
    #rest: [], Ex: [], In: [], ER: [],
    #asl: [], m0: []
}

def get_latest_series(key, s):
    info[key].append(s.series_id)

for s in seqinfo:
    protocol = s.protocol_name.lower()

    if "MPRAGE" in s.series_description:
        if "SC" in s.series_description:
            get_latest_series(t1w_SC, s)
        else:
            get_latest_series(t1w, s)
    elif "DTI" in s.series_description:
            get_latest_series(dwi, s)
    elif "Field map" in s.series_description:
        if "Field_map" and "e1" in s.dcm_dir_name:
            if s.dcm_dir_name.endswith("_ph"):
                get_latest_series(b0_phase1)
            elif s.dcm_dir_name.endswith("_pha"):
                get_latest_series(b0_phase2)
            elif s.dcm_dir_name.endswith("_e1"):
                get_latest_series(b0_mag1)
            elif s.dcm_dir_name.endswith("_e1a"):
                get_latest_series(b0_mag2)
            else:
                continue
        elif "Field_map" and "e2" in s.dcm_dir_name:
            if "ph" in s.dcm_dir_name:
                get_latest_series(b0_phase2)
            else:
                get_latest_series(b0_mag2, s)
        elif "gre_field_mapping" and "ph" in s.dcm_dir_name:
            get_latest_series(b0_phase, s)
        else:
            get_latest_series(b0_mag2, s)
    elif "gre_field_mapping" in s.series_description:
        if "gre_field_mapping" and "e1" in s.dcm_dir_name:
            if "ph" in s.dcm_dir_name:
                get_latest_series(b0_phase1)
            else:
                get_latest_series(b0_mag1, s)
        if "gre_field_mapping" and "e2" in s.dcm_dir_name:
            if "ph" in s.dcm_dir_name:
                get_latest_series(b0_phase2)
            else:
                get_latest_series(b0_mag2, s)
        elif "gre_field_mapping" and "ph" in s.dcm_dir_name:
            get_latest_series(b0_phase, s)
        else:
            get_latest_series(b0_mag2, s)
return info

Please paste any relevant output below

INFO: Applying heuristic to T12 (1/102)... Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.10/bin/fw-heudiconv-curate", line 8, in sys.exit(main()) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/fw_heudiconv/cli/curate.py", line 326, in main convert_to_bids(client=fw, File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/fw_heudiconv/cli/curate.py", line 185, in convert_to_bids seq_infos = get_seq_info(client, project_label, [session]) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/fw_heudiconv/backend_funcs/query.py", line 176, in get_seq_info for key, val in session_to_seq_info(client, session, context).items(): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/fw_heudiconv/backend_funcs/query.py", line 115, in session_to_seq_info for info in acquisition_to_heudiconv(client, acquisition, context): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/fw_heudiconv/backend_funcs/query.py", line 60, in acquisition_to_heudiconv to_convert.append(utils.SeqInfo( TypeError: SeqInfo.new() missing 1 required positional argument: 'time'

Add any additional context or information below

TinasheMTapera commented 2 years ago

Will probably just need to implement and adjust locally: https://github.com/nipy/heudiconv/blob/80713f8e2a4e0f25e40eaed28cc5a9ed0c3b5ac9/heudiconv/utils.py#L27-L53

nickwell13 commented 2 years ago

Implement how exactly? Add the highlighted section to my script?

TinasheMTapera commented 2 years ago

Ignore, just a comment for myself, a fix is in the works

nickwell13 commented 2 years ago

Awesome. Thanks.

TinasheMTapera commented 2 years ago

@nickwell13 this should be updated on flywheel now, you can also update your local copy by downloading the latest version from pip pip install -U fw-heudiconv

nickwell13 commented 2 years ago

When running fw-heudiconv-tabulate I receive the same 'time' error. When running fw-heudiconv-curate I receive the error that "module 'collections' has no attribute 'MutableMapping'". Here is the full error message: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.10/bin/fw-heudiconv-curate", line 8, in sys.exit(main()) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/fw_heudiconv/cli/curate.py", line 326, in main convert_to_bids(client=fw, File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/fw_heudiconv/cli/curate.py", line 104, in convert_to_bids project_obj = confirm_bids_namespace(project_obj, dry_run) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/fw_heudiconv/backend_funcs/convert.py", line 340, in confirm_bids_namespace project_obj.update_info(bids) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flywheel/models/mixins.py", line 136, in update_info body = util.params_to_dict("update_info", args, kwargs) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flywheel/util.py", line 53, in params_to_dict elif not isinstance(args[0], collections.MutableMapping) and not hasattr( AttributeError: module 'collections' has no attribute 'MutableMapping'

TinasheMTapera commented 2 years ago

could you do pip show fw-heudiconv

nickwell13 commented 2 years ago

Name: fw-heudiconv Version: 0.4.3 Summary: Use heudiconv-like heuristics for BIDS curation on flywheel Home-page: https://github.com/PennBBL/fw_heudiconv Author: Tinashe M. Tapera, Matt Cieslak, Harsha Kethineni Author-email: tinashemtapera@gmail.com License: 3-clause BSD Location: /Users/nickwell/Library/Python/2.7/lib/python/site-packages Requires: bids-validator, pathvalidate, flywheel-sdk, nibabel, pytest, pytest-cov, validators, pandas, heudiconv

TinasheMTapera commented 2 years ago

hmmm..... I'm not sure I like this Location: /Users/nickwell/Library/Python/2.7/lib/python/site-packages

Could you create a new environment with conda with specifically python 3.7 and reinstall fwheudiconv there?

nickwell13 commented 2 years ago

Tried this. I'm now receive "fw-heudiconv-curate: Command not found" within as well as outside of my conda environment. fw status shows I'm logged into fw CLI and I've upgraded to the most recent version of fw sdk. It shows up if I do "pip show fw-heudiconv": Name: fw-heudiconv Version: 0.4.3 Summary: Use heudiconv-like heuristics for BIDS curation on flywheel Home-page: https://github.com/PennBBL/fw_heudiconv Author: Tinashe M. Tapera, Matt Cieslak, Harsha Kethineni Author-email: tinashemtapera@gmail.com License: 3-clause BSD Location: /Users/nickwell/opt/miniconda3/envs/flywheel3.7/lib/python3.7/site-packages Requires: nibabel, flywheel-sdk, bids-validator, heudiconv, pytest-cov, validators, pandas, pytest, pathvalidate

TinasheMTapera commented 2 years ago

TBH you might wanna nuke your conda and start over if possible... I have a feeling something broke outside of the scope of this fwheudiconv issue https://docs.anaconda.com/anaconda/install/uninstall/

nickwell13 commented 2 years ago

That did the trick! Thanks so much for the help.

TinasheMTapera commented 2 years ago

Love to see it