def make_chunks(physiological_file_id, config_file, verbose): """ Call the function create_chunks_for_visualization of the Physiology class on the PhysiologicalFileID provided as argument to this function. :param physiological_file_id: PhysiologicalFileID of the file to chunk :type physiological_file_id: int :param config_file: path to the config file with database connection information :type config_file: str :param verbose : flag for more printing if set :type verbose : bool """ # database connection db = Database(config_file.mysql, verbose) db.connect() # grep config settings from the Config module data_dir = db.get_config('dataDirBasepath') # making sure that there is a final / in data_dir data_dir = data_dir if data_dir.endswith('/') else data_dir + "/" # load the Physiological object physiological = Physiological(db, verbose) # create the chunked dataset if physiological.grep_file_path_from_file_id(physiological_file_id): print('Chunking physiological file ID ' + str(physiological_file_id)) physiological.create_chunks_for_visualization(physiological_file_id, data_dir)
def register_raw_data(self): """ Registers raw EEG data and related files into the following tables: - physiological_file - physiological_parameter_file - physiological_electrode - physiological_channel - physiological_task_event """ # insert EEG file inserted_eeg = self.fetch_and_insert_eeg_file() eeg_file_id = inserted_eeg['file_id'] eeg_file_path = inserted_eeg['eeg_path'] # insert related electrode, channel and event information electrode_file_path = self.fetch_and_insert_electrode_file(eeg_file_id) channel_file_path = self.fetch_and_insert_channel_file(eeg_file_id) event_file_path = self.fetch_and_insert_event_file(eeg_file_id) # grep the path to the fdt file is present in # physiological_parameter_file for that PhysiologicalFileID physiological = Physiological(self.db, self.verbose) results = physiological.grep_parameter_value_from_file_id( eeg_file_id, 'fdt_file') fdt_file_path = results['Value'] if results else None # archive all files in a tar ball for downloading all files at once files_to_archive = (self.data_dir + eeg_file_path, ) if electrode_file_path: files_to_archive = files_to_archive + (self.data_dir + electrode_file_path, ) if fdt_file_path: # add the fdt file path to the tuple if present files_to_archive = files_to_archive + (self.data_dir + fdt_file_path, ) if event_file_path: files_to_archive = files_to_archive + (self.data_dir + event_file_path, ) if channel_file_path: files_to_archive = files_to_archive + (self.data_dir + channel_file_path, ) archive_rel_name = os.path.splitext(eeg_file_path)[0] + ".tgz" self.create_and_insert_archive(files_to_archive, archive_rel_name, eeg_file_id) # create data chunks for React visualization in # data_dir/bids_import/bids_dataset_name_BIDSVersion_chunks directory physiological.create_chunks_for_visualization(eeg_file_id, self.data_dir)