From 88c1edc26d44ef3297bf1836fb1dde903c1dfff7 Mon Sep 17 00:00:00 2001 From: Ji Hyun Bak Date: Fri, 6 Nov 2020 16:18:42 -0800 Subject: [PATCH 1/2] separate a private method __build_nwb_files --- rec_to_nwb/processing/builder/raw_to_nwb_builder.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rec_to_nwb/processing/builder/raw_to_nwb_builder.py b/rec_to_nwb/processing/builder/raw_to_nwb_builder.py index 673613b2c..8e2c08a5a 100644 --- a/rec_to_nwb/processing/builder/raw_to_nwb_builder.py +++ b/rec_to_nwb/processing/builder/raw_to_nwb_builder.py @@ -147,7 +147,19 @@ def build_nwb(self, process_mda_valid_time=True, process_mda_invalid_time=True, """ self.__preprocess_data() + + self.__build_nwb_file(process_mda_valid_time=process_mda_valid_time, + process_mda_invalid_time=process_mda_invalid_time, + process_pos_valid_time=process_pos_valid_time, + process_pos_invalid_time=process_pos_invalid_time) + + def __build_nwb_file(self, process_mda_valid_time=True, process_mda_invalid_time=True, + process_pos_valid_time=True, process_pos_invalid_time=True): + logger.info('Building NWB files') + os.makedirs(self.output_path, exist_ok=True) + os.makedirs(self.video_path, exist_ok=True) for date in self.dates: + logger.info('Date: {}'.format(date)) nwb_builder = NWBFileBuilder( data_path=self.data_path, animal_name=self.animal_name, @@ -241,4 +253,3 @@ def cleanup(self): preprocessing = self.data_path + '/' + self.animal_name + '/preprocessing' if os.path.exists(preprocessing): shutil.rmtree(preprocessing) - From ab5a68294ae6c74bfa664069eb75f6132a2ffe31 Mon Sep 17 00:00:00 2001 From: Ji Hyun Bak Date: Thu, 12 Nov 2020 14:33:40 -0800 Subject: [PATCH 2/2] add method get_nwb_builder to RawToNWBBuilder --- .../processing/builder/raw_to_nwb_builder.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/rec_to_nwb/processing/builder/raw_to_nwb_builder.py b/rec_to_nwb/processing/builder/raw_to_nwb_builder.py index 8e2c08a5a..419b1d45b 100644 --- a/rec_to_nwb/processing/builder/raw_to_nwb_builder.py +++ b/rec_to_nwb/processing/builder/raw_to_nwb_builder.py @@ -160,18 +160,7 @@ def __build_nwb_file(self, process_mda_valid_time=True, process_mda_invalid_time os.makedirs(self.video_path, exist_ok=True) for date in self.dates: logger.info('Date: {}'.format(date)) - nwb_builder = NWBFileBuilder( - data_path=self.data_path, - animal_name=self.animal_name, - date=date, - nwb_metadata=self.nwb_metadata, - output_file=self.output_path + self.animal_name + date + ".nwb", - process_mda=self.extract_mda, - process_dio=self.extract_dio, - process_analog=self.extract_analog, - video_path=self.video_path, - reconfig_header=self.__is_rec_config_valid() - ) + nwb_builder = self.get_nwb_builder(date) content = nwb_builder.build() nwb_builder.write(content) self.append_to_nwb( @@ -182,6 +171,20 @@ def __build_nwb_file(self, process_mda_valid_time=True, process_mda_invalid_time process_pos_invalid_time=process_pos_invalid_time ) + def get_nwb_builder(self, date): + return NWBFileBuilder( + data_path=self.data_path, + animal_name=self.animal_name, + date=date, + nwb_metadata=self.nwb_metadata, + output_file=self.output_path + self.animal_name + date + ".nwb", + process_mda=self.extract_mda, + process_dio=self.extract_dio, + process_analog=self.extract_analog, + video_path=self.video_path, + reconfig_header=self.__is_rec_config_valid() + ) + def __preprocess_data(self): """process data with rec_to_binaries library"""