def __init__(self, phases=None, freqs=None, masks=None): if id(phases) != id(None) & id(freqs) != id(None): self.phases = np.squeeze(np.array(phases, dtype=np.float32)) self.phases = (self.phases % (2 * np.pi) + 2 * np.pi) % (2 * np.pi) self.freqs = np.squeeze(np.array(freqs, dtype=np.float32)) if masks is not None: self.fps = loss_func_ex.fpt_btw_groups_np(self.phases, masks) self.inps = loss_func_ex.inp_btw_groups_np2(self.phases, masks) self.chs = loss_func_ex.coh_btw_groups_np(self.phases, masks) self.abs = loss_func_ex.abs_angle_diffs_np(self.phases) else: self.fps = loss_func_ex.frame_pt_np(self.phases) self.inps = loss_func_ex.inp_np(self.phases) self.chs = loss_func_ex.coherence_np(self.phases) self.abs = loss_func_ex.abs_angle_diffs_np(self.phases) self.masks = masks assert len(self.phases.shape) == 2 assert len(self.freqs.shape) == 2 assert len(self.fps.shape) == 1 assert len(self.inps.shape) == 1 assert len(self.chs.shape) == 1 assert len(self.abs.shape) == 1 else: self.phases = None self.freqs = None self.fps = None self.inps = None self.abs = None self.chs = None self.masks = masks
def __init__(self, interactive=False, phases=None, freqs=None, masks=None): if interactive: import matplotlib.pyplot as plt global plt else: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt plt.ioff() global plt if id(phases) != id(None) & id(freqs) != id(None): self.phases = np.squeeze(np.array(phases, dtype=np.float32)) self.phases = (self.phases % (2 * np.pi) + 2 * np.pi) % (2 * np.pi) self.freqs = np.squeeze(np.array(freqs, dtype=np.float32)) if masks is not None: self.fps = loss_func_ex.fpt_btw_groups_np(self.phases, masks) self.inps = loss_func_ex.inp_btw_groups_np(self.phases, masks) # Originally this ^^ said `np2` self.chs = loss_func_ex.coh_btw_groups_np(self.phases, masks) self.abs = loss_func_ex.abs_angle_diffs_np(self.phases) else: self.fps = loss_func_ex.frame_pt_np(self.phases) self.inps = loss_func_ex.inp_np(self.phases) self.chs = loss_func_ex.coherence_np(self.phases) self.abs = loss_func_ex.abs_angle_diffs_np(self.phases) self.masks = masks assert len(self.phases.shape) == 2 assert len(self.freqs.shape) == 2 assert len(self.fps.shape) == 1 assert len(self.inps.shape) == 1 assert len(self.chs.shape) == 1 assert len(self.abs.shape) == 1 else: self.phases = None self.freqs = None self.fps = None self.inps = None self.abs = None self.chs = None self.masks = masks
def compute_properties(self): if self.phases is not None: if self.masks is None: self.fps = loss_func_ex.frame_pt_np(self.phases) self.inps = loss_func_ex.inp_np(self.phases) self.chs = loss_func_ex.coherence_np(self.phases) self.abs = loss_func_ex.abs_angle_diffs_np(self.phases) else: self.fps = loss_func_ex.fpt_btw_groups_np(self.phases, self.masks) self.inps = loss_func_ex.inp_btw_groups_np(self.phases, self.masks) self.chs = loss_func_ex.coh_btw_groups_np(self.phases, self.masks) self.abs = loss_func_ex.abs_angle_diffs_np(self.phases) assert len(self.fps.shape) == 1 assert len(self.inps.shape) == 1 assert len(self.chs.shape) == 1 assert len(self.abs.shape) == 1 else: raise ValueError('No phases provided')