Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! Reading the dataset: ds003774
- #? https://mne.tools/mne-bids/dev/generated/mne_bids.BIDSPath.html#mne_bids.BIDSPath
- # https://mne.tools/mne-bids/stable/generated/mne_bids.BIDSPath.html#mne_bids.BIDSPath
- # https://mne.tools/mne-bids/dev/api.html?highlight=mne#module-mne_bids
- # from _typeshed import NoneType
- import os
- import os.path as op
- import openneuro
- from mne.datasets import sample
- from mne_bids import BIDSPath, read_raw_bids, print_dir_tree, make_report
- # functions declarations
- # to find the index of the raw EEG
- def find_EEG_index():
- eeg_extension = ['.vhdr', '.edf', '.bdf', '.set']
- intersection_set = list(set.intersection(set(extension), set(eeg_extension)))
- return(extension.index(intersection_set[0]))
- # Settings of the Variables with the content of the dataset
- dataset ='ds003774'
- # subject str | None
- # The subject ID. Corresponds to “sub”.
- subject = ['001','002','003','004','005','006','007','008','009','010','011','012','013','014','015','016','017','018','019','020']
- # session str | None
- # The acquisition session. Corresponds to “ses”.
- session = ['01','02','03','04','05','06','07','08','09','10','11','12']
- # task str | None
- # The experimental task. Corresponds to “task”.
- task=['MusicListening']
- # acquisition: str | None
- # The acquisition parameters. Corresponds to “acq”.
- acquisition= []
- # run int | None
- # The run number. Corresponds to “run”.
- run = [1,2,3,4,5,6,7,8,9,10,11,12]
- # processing str | None
- # The processing label. Corresponds to “proc”.
- processing= [ ]
- # recordingstr | None
- # The recording name. Corresponds to “rec”.
- recording= [ ]
- # spacestr | None
- # The coordinate space for anatomical and sensor location files (e.g., *_electrodes.tsv, *_markers.mrk). Corresponds to “space”. Note that valid values for space must come from a list of BIDS keywords as described in the BIDS specification.
- space= [ ]
- # split int | None
- # The split of the continuous recording file for .fif data. Corresponds to “split”.
- split = [ ]
- # suffix str | None
- # The filename suffix. This is the entity after the last _ before the extension. E.g., 'channels'. The following filename suffix's are accepted: 'meg', 'markers', 'eeg', 'ieeg', 'T1w', 'participants', 'scans', 'electrodes', 'coordsystem', 'channels', 'events', 'headshape', 'digitizer', 'beh', 'physio', 'stim'
- suffix = ['channels', 'coordsystem','eeg', 'eeg', 'electrodes', 'events','events']
- # extension str | None
- # The extension of the filename. E.g., '.json'.
- extension = ['.tsv','.json','.json','.set', '.tsv', '.json','.tsv' ]
- # datatype str
- # The BIDS data type, e.g., 'anat', 'func', 'eeg', 'meg', 'ieeg'.
- datatype = 'eeg'
- # rootpath-like | None
- # The root directory of the BIDS dataset.
- root = '/home/angelicaribeiro/Insync/angelribeiro@usp.br/OneDrive Biz/Datasets/OpenNeuro/ds003774/'
- # check: bool
- # If True, enforces BIDS conformity. Defaults to True.
- check = True
- "___________________________________________________________________________________________________________________________"
- # Setting the bids_path of the first session, the first subject, and the fist run, and the first task
- bids_path = BIDSPath(subject = subject[0],\
- session = None if len(session) == 0 else session[0],\
- task = None if len(task) == 0 else task[0],\
- acquisition = None if len(acquisition) == 0 else acquisition[0],\
- run = None if len(run) == 0 else run[0],\
- processing = None if len(processing) == 0 else processing[0],\
- recording = None if len(recording) == 0 else recording[0],\
- space = None if len(space) == 0 else space[0],\
- split = None if len(split) == 0 else split[0],\
- suffix = suffix[find_EEG_index()],\
- extension = extension[find_EEG_index()],\
- datatype = datatype,\
- root = root,\
- check = check )
- print_dir_tree(root, max_depth=4)
- print(bids_path.match())
- print("Since the run variable is an integer \'1\' not an string \'01\' \n")
- print("bids_path is : "+ str(bids_path))
- print("\nbids_path should be:"+ "~~~~/Datasets/OpenNeuro/ds003774/sub-001/ses-01/eeg/sub-001_ses-01_task-MusicListening_run-1_eeg.set")
- print("\nThe file in \'bids_path\' doesn\'t exist")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement