Skip to content

fix: session string parsing doesn't work with ephys sessions#126

Open
galenlynch wants to merge 1 commit intomainfrom
fix/session-parsing
Open

fix: session string parsing doesn't work with ephys sessions#126
galenlynch wants to merge 1 commit intomainfrom
fix/session-parsing

Conversation

@galenlynch
Copy link
Copy Markdown
Member

Ephys sessions have names like ecephys_<subject>_<date>_<time>, and the current session parsing logic depends on the exact number and placement of underscores, causing these functions to not work for ephys nwbs.

ephys sessions have names like ecephys_<subject>_<date>_<time>, and the current
session parsing logic depends on the exact number and placement of underscores.
@alexpiet
Copy link
Copy Markdown
Collaborator

Would it be simpler to just use

    if nwb.session_id.startswith("behavior") or nwb.session_id.startswith("FIP") or nwb.session_id.startswith("ecephys"):
        splits = nwb.session_id.split("_")
        subject_id = splits[1]
        session_date = splits[2]
    else:
        splits = nwb.session_id.split("_")
        subject_id = splits[0]
        session_date = splits[1]

The <subject>_<date>_<time> part of the ecephys session ids are the same standard format.

Note here that the only reason we are parsing session names at all is because metadata is not added to the NWB files

@galenlynch
Copy link
Copy Markdown
Member Author

What about another modality besides ecephys, behavior, or FIP? I personally don't find regexs that complicated, and I think they're often the "right" tool for this job of string parsing - they are expressive enough to represent what you actually mean. In this case the function is finding the first substring (re.search) that matches the subject ID, date, and optionally time, format that neural dynamics uses. Otherwise we will have to special case for each new modality, modality with a underscore in it, or another strangely formatted session_id that is there because the universe hates developers.

That being said I just want it to work with ecephys sessions, so if you don't want to use a regex I'm fine using string splitting on underscores for now.

@alexpiet
Copy link
Copy Markdown
Collaborator

metadata 2.0 removes the modality prefix anyways, so this issue will go away eventually.

I think for readability, splitting by "_" is way easier to understand than a regex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants