def setUpClass(cls): config = SetupConfig() path = os.path.join(data_path, "weird_short_3_mice") raw_data = uf.read_single_file(path, "20101010_110000.txt") data = uf.from_raw_data(raw_data) cls.mismatch1 = uf.antenna_mismatch(data, config) cls.presences1 = uf.check_antenna_presence(data, config, 24 * 3600) res_path = os.path.join(path, "Results") files = glob.glob(os.path.join(res_path + "/diagnostics/*.csv")) for f in files: print("rm ", f) cls.length = len(data["Antenna"]) out1 = uf.run_diagnostics(data, 24 * 3600, res_path, config) cls.str11, cls.str12, cls.str13, cls.str14, cls.str15 = out1 path = os.path.join(data_path, "weird_short") raw_data = uf.read_single_file(path, "20101010_110000.txt") data = uf.from_raw_data(raw_data) cls.mismatch2 = uf.antenna_mismatch(data, config) cls.presences2 = uf.check_antenna_presence(data, config, 24 * 3600) res_path = os.path.join(path, "Results") files = glob.glob(os.path.join(res_path + "/diagnostics/*.csv")) for f in files: os.remove(f) out2 = uf.run_diagnostics(data, 24 * 3600, res_path, config) cls.str21, cls.str22, cls.str23, cls.str24, cls.str25 = out2 path1 = os.path.join(data_path, "weird_very_short_3_mice") raw_data1 = uf.read_single_file(path1, "20101010_110000.txt") data1 = uf.from_raw_data(raw_data1) config1 = SetupConfig() res_path1 = os.path.join(path1, "Results") out = uf.run_diagnostics(data1, 24 * 3600, res_path1, config1) cls.incorr_tunnel = out[-1]
def setUpClass(cls): cls.path1 = os.path.join(data_path, "modular_1", "data_setup_additional") cls.dataset1 = Loader(cls.path1, visit_threshold=1.5, prefix="gugu") cls.setup1 = SetupConfig(cls.path1) cls.dataset1_standard = Loader(cls.path1) cls.path2 = os.path.join(data_path, "weird_very_short") cls.dataset2 = Loader(cls.path2, visit_threshold=2) cls.setup3 = SetupConfig(path=data_path, fname="setup_short.txt") cls.dataset3 = Loader(cls.path1, visit_threshold=1.5, setup_config=cls.setup3, remove_antennas=["8"]) cls.path_empty = os.path.join(data_path, "empty")
def setUpClass(cls): path = os.path.join(data_path, "weird_short") raw_data = uf.read_single_file(path, "20101010_110000.txt") data = uf.from_raw_data(raw_data) setup_config = SetupConfig() cls.data = EcoHabDataBase(data, None, 2, setup_config) cls.config = Timeline(path)
def setUpClass(cls): config = SetupConfig() cls.mismatched_pairs = config.mismatched_pairs path = os.path.join(data_path, "weird_short_3_mice") raw_data1 = uf.read_single_file(path, "20101010_110000.txt") cls.data1 = uf.from_raw_data(raw_data1) cls.mismatch1 = uf.antenna_mismatch(cls.data1, config) path = os.path.join(data_path, "weird_short") raw_data2 = uf.read_single_file(path, "20101010_110000.txt") cls.data2 = uf.from_raw_data(raw_data2) cls.mismatch2 = uf.antenna_mismatch(cls.data2, config)
def __init__(self, path, **kwargs): # Read in parameters self.path = path setup_config = kwargs.pop('setup_config', None) if isinstance(setup_config, SetupConfig): antennas = setup_config elif isinstance(setup_config, str): antennas = SetupConfig(path=setup_config) else: antennas = SetupConfig(path=self.path) self.mask = kwargs.pop('mask', None) self.visit_threshold = kwargs.pop('visit_threshold', 2.) add_date = kwargs.pop('add_date', True) res_dir = kwargs.pop("res_dir", "Results") self.prefix = kwargs.pop("prefix", ufl.make_prefix(self.path)) self.max_break = kwargs.pop("max_break", self.MAX_BREAK) remove_antennas = kwargs.pop('remove_antennas', []) tags = kwargs.pop('legal_tags', "ALL") if add_date: today = date.today().strftime("%d.%m.%y") res_dir = "%s_%s" % (res_dir, today) self.res_dir = ufl.results_path(self.path, res_dir) # Read in data rawdata = self._read_in_raw_data(tags) data = ufl.from_raw_data(rawdata) data = ufl.remove_antennas(data, remove_antennas) # As in antenna registrations ufl.run_diagnostics(data, self.max_break, self.res_dir, antennas) super(Loader, self).__init__(data, self.mask, self.visit_threshold, antennas) self.cages = antennas.cages self.directions = antennas.directions self.setup_config = antennas self.all_antennas = antennas.all_antennas self.internal_antennas = antennas.internal_antennas self.setup_name = antennas.name self.home_antenna = antennas.homecage_antenna self.home_internal_antennas = antennas.homecage_internal_antennas self.stimulus_internal_antennas = antennas.stimCage_internal_antennas
def setUpClass(cls): antennas = ["1", "2", "1", "2", "3", "4", "5", "6", "7"] times = [1, 2, 2.5, 3, 4.5, 5.5, 6.5, 7.5, 10.5] durations = [3, 600, 3, 34, 55, 66, 1999, 200, 100] cls.pred_out = {"1 2": 1, "3 4": 0, "5 6": 1, "7 8": 0} keys = cls.pred_out.keys() cls.out, cls.tot = uf.incorrect_tunnel_single_mouse( keys, antennas, times, durations) cls.pred_tot = {"1 2": 3, "3 4": 1, "5 6": 1, "7 8": 0} path = os.path.join(data_path, "weird_very_short_3_mice") cls.raw_data = uf.read_single_file(path, "20101010_110000.txt") cls.data = uf.from_raw_data(cls.raw_data) config = SetupConfig() cls.out_i, cls.out_tot_i = uf.incorrect_tunnel_registrations( cls.data, config) cls.pred_out_i = {"1 2": 0, "3 4": 0, "5 6": 2, "7 8": 0} cls.pred_tot_i = {"1 2": 2, "3 4": 1, "5 6": 7, "7 8": 0}
def setUpClass(cls): path = os.path.join(data_path, "weird_short_3_mice") raw_data = uf.read_single_file(path, "20101010_110000.txt") data = uf.from_raw_data(raw_data) cls.config = SetupConfig() cls.presences = uf.check_antenna_presence(data, cls.config, 24 * 3600) cls.end = data["Time"][-1] cls.begs = [] for key in cls.presences.keys(): if len(cls.presences[key]): cls.begs.append(cls.presences[key][0][0]) cls.begs_data = [] for antenna in ["1", "2", "3", "4", "5", "6", "7", "8"]: if antenna == "4": continue idx = np.where(data["Antenna"] == antenna)[0][-1] cls.begs_data.append(np.round(data["Time"][idx]))
def setUpClass(cls): path = os.path.join(data_path, "weird_short_3_mice") raw_data = uf.read_single_file(path, "20101010_110000.txt") data = uf.from_raw_data(raw_data) config = SetupConfig() cls.mismatch1 = uf.skipped_registrations(data, config)