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

Qc-meg #30

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 0 additions & 7 deletions coglib/meeg/qc/P00_bids_conversion.py
Copy link
Collaborator

@oscfer88 oscfer88 Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this script can be removed given that we are already provide the BIDS converted data @Urszula11 ?

Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@

https://mne.tools/mne-bids/stable/index.html

Questions/Issues:
- what to write in the participants and dataset_description metadata
files?
- what session ID should we give to the anat scan (e.g., v0, v2, mri)?
- for visit 2, what to count the replay runs? Continue the count from
where it was left from the VG (run 4) or restart from run 1?

Notes:
- the conversion must be done after reading the events. Here, the event
list includes all the triggers/events
Expand Down
42 changes: 0 additions & 42 deletions coglib/meeg/qc/P00_run_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,4 @@
has_eeg = True


# # =============================================================================
# # DEFINE PREPROCESSING STEPS
# # =============================================================================

# def pre_step1():
# P01_maxwell_filtering.run_maxwell_filter(subject_id,
# visit_id)
# if has_eeg:
# P02_find_bad_eeg.find_bad_eeg(subject_id,
# visit_id,
# has_eeg)
# P03_artifact_annotation.artifact_annotation(subject_id,
# visit_id,
# has_eeg,
# # threshold_muscle,
# )
# P04_extract_events.run_events(subject_id,
# visit_id)
# P05_run_ica.run_ica(subject_id,
# visit_id,
# has_eeg)

# def pre_step2(
# # meg_ica_eog=opt.mICA_eog, meg_ica_ecg=opt.mICA_ecg,
# # eeg_ica_eog=opt.eICA_eog, eeg_ica_ecg=opt.eICA_ecg,
# ):
# P06_apply_ica.apply_ica(subject_id,
# visit_id,
# has_eeg)

# P07_make_epochs.run_epochs(subject_id,
# visit_id,
# has_eeg)


# =============================================================================
# RUN
# =============================================================================
# if opt.step == '1':
# pre_step1()
# elif opt.step == '2':
# pre_step2()
QC_processing.run_qc_processing(subject_id, visit_id, has_eeg)
82 changes: 0 additions & 82 deletions coglib/meeg/qc/P00_run_qc_epochs.py

This file was deleted.

31 changes: 0 additions & 31 deletions coglib/meeg/qc/QC_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,37 +189,6 @@ def run_qc_epochs(subject_id, visit_id, has_eeg):
epochs_irr_O = epochs['Trial_type == "Filler" and Stimuli_type == "Blank"']
print(epochs_irr_O)

#types0 = ['Filler', 'Probe']
#type1 = ['Face', 'Object', 'Blank']
#location = ['Upper Left', 'Upper Right', 'Lower Right', 'Lower Left']
#response = ['Seen', 'Unseen']

#print(epochs[['face1', 'face2','face3','face4','face5','face6','face7','face8','face9','face10']])
#print(epochs[['object1', 'object2','object3','object4','object5','object6','object7','object8','object9','object10']])
#print(epochs[['letter1', 'letter2','letter3','letter4','letter5','letter6','letter7','letter8','letter9','letter10']])
#print(epochs[['false1', 'false2','false3','false4','false5','false6','false7','false8','false9','false10']])

# Get rejection thresholds - MEG only
#reject = get_rejection_threshold(epochs, ch_types=['mag', 'grad'], #'eeg'],
# decim=2)

# Drop bad epochs based on peak-to-peak magnitude
#epochs.drop_bad(reject=reject)

#print("VERY_IMPORTANT EPOCHS faces after drop")
#epochs_rel_F = epochs['Task_relevance == "Relevant non-target" and Category == "face"']
#print(epochs_rel_F)
#print(epochs[['face1', 'face2','face3','face4','face5','face6','face7','face8','face9','face10']])
#print(epochs[['object1', 'object2','object3','object4','object5','object6','object7','object8','object9','object10']])
#print(epochs[['letter1', 'letter2','letter3','letter4','letter5','letter6','letter7','letter8','letter9','letter10']])
#print(epochs[['false1', 'false2','false3','false4','false5','false6','false7','false8','false9','false10']])

#print("VERY_IMPORTANT DROP LOG")
#print(epochs.drop_log)

# Plot percentage of rejected epochs per channel
#fig1 = epochs.plot_drop_log()
#pdf.savefig(fig1)
plt.close()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure whether line 192 ( plt.close() ) should be removed or not

Copy link
Collaborator

@oscfer88 oscfer88 Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I didn't notice that this file was deleted in a following commit. Ignore this comment @Urszula11



Expand Down
35 changes: 2 additions & 33 deletions coglib/meeg/qc/QC_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def run_qc_processing(subject_id, visit_id, has_eeg):
# check=False)
#epochs = mne.read_epochs(bids_path_epo.fpath, preload=False)

print("VERY_IMPORTANT EPOCHS faces") # save outputs to pdf for everyone to access
print("EPOCHS before drop check - faces") # save outputs to pdf for everyone to access
epochs_rel_F = epochs['Task_relevance == "Relevant non-target" and Category == "face"']
print(epochs_rel_F)
#print(epochs[['face1', 'face2','face3','face4','face5','face6','face7','face8','face9','face10']])
Expand All @@ -356,7 +356,7 @@ def run_qc_processing(subject_id, visit_id, has_eeg):
# Drop bad epochs based on peak-to-peak magnitude
epochs.drop_bad(reject=reject)

print("VERY_IMPORTANT AFTER DROP :)")
print("EPOCHS AFTER DROP :)")
print("FACES task relevant")
epochs_rel_F = epochs['Task_relevance == "Relevant non-target" and Category == "face"']
print(epochs_rel_F)
Expand Down Expand Up @@ -423,38 +423,7 @@ def run_qc_processing(subject_id, visit_id, has_eeg):
#fig1 = epochs.plot_drop_log()
#pdf.savefig(fig1)
#plt.close()


# Epoch raw data 3/3
#epochs = mne.Epochs(raw,
# events,
# events_id,
# tmin, tmax,
# baseline=None,
# proj=True,
# picks=picks,
# detrend=1,
# reject=None,
# reject_by_annotation=True,
# verbose=True)

#del raw

# Add metadata
#epochs.metadata = metadata

# Get rejection thresholds - all
#reject = get_rejection_threshold(epochs, ch_types=['mag', 'grad', 'eeg'],
# decim=2)

# Drop bad epochs based on peak-to-peak magnitude
#epochs.drop_bad(reject=reject)

# Plot percentage of rejected epochs per channel
#fig1 = epochs.plot_drop_log()
#pdf.savefig(fig1)
#plt.close()

if __name__ == '__main__':
subject_id = input("Type the subject ID (e.g., SA101)\n>>> ")
visit_id = input("Type the visit ID (V1 or V2)\n>>> ")
Expand Down
Loading