-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
def create_subjects_mne_objects_dict(subjects, epochs_root_file, conditions, task, just_HG_ev1_rescaled=False, LAB_root=None, acc_trials_only=True):
"""
Adjusted to handle multiple conditions per output name, with multiple condition columns.
Parameters:
- subjects: List of subject IDs.
- output_names_conditions: Dictionary where keys are output names and values are dictionaries
of condition column names and their required values.
- task: Task identifier.
- combined_data: DataFrame with combined behavioral and trial information.
- acc_array: dict of numpy arrays of 0 for incorrect and 1 for correct trials for each subject
- LAB_root: Root directory for data (optional).
"""
subjects_mne_objects = {}
for sub in subjects:
print(f"Loading data for subject: {sub}")
sub_mne_objects = {}
mne_objects = load_mne_objects(sub, epochs_root_file, task, just_HG_ev1_rescaled=just_HG_ev1_rescaled, LAB_root=LAB_root)
for mne_object in mne_objects.keys():
if acc_trials_only == True:
mne_objects[mne_object] = mne_objects[mne_object]["Accuracy1.0"] # this needs to be done for all the epochs objects I think. So loop over them. Unless it's set to just_HG_ev1_rescaled.
for condition_name, condition_parameters in conditions.items():
print(f" Loading condition: {condition_name} with parameters: {condition_parameters}")
# Get BIDS events from the conditions, and remove it so it doesn't complicate future analyses.
bids_events = condition_parameters.get("BIDS_events")
if bids_events is None:
print(f"Warning: condition {condition_name} is missing 'BIDS_events'. Fix this!")
# if multiple bids events are part of this condition, concatenate their epochs. Otherwise just grab epochs.
if isinstance(bids_events, list):
combined_epochs = []
for event in bids_events:
partial_event_epochs = mne_objects[mne_object][event]
combined_epochs.append(partial_event_epochs)
event_epochs = mne.concatenate_epochs(combined_epochs)
else:
event_epochs = mne_objects[mne_object][bids_events]
sub_mne_objects[condition_name] = {}
sub_mne_objects[condition_name][mne_object] = event_epochs
subjects_mne_objects[sub] = sub_mne_objects
return subjects_mne_objects
This is because the Evoked object is not subscriptable using the [Accuracy1.0] BIDS naming, as seen below.
mne_objects[mne_object] = mne_objects[mne_object]["Accuracy1.0"] # this needs to be done for all the epochs objects I think. So loop over them. Unless it's set to just_HG_ev1_rescaled.
Metadata
Metadata
Assignees
Labels
No labels