def buriedness_grid(self): closed_g = self._multiscale_closing(self.protein_grid) out_g = self._open_grid(closed_g, 2) * closed_g out_array = out_g.get_array() scaled_g = Grid.initalise_grid(self.out_grid.bounding_box, padding=0, spacing=0.5) scaled_array = resize(out_array, scaled_g.nsteps, anti_aliasing=False) # Future tweaking here final_array = scaled_array return Grid.array_to_grid(final_array.astype(int), scaled_g)
def normalize_to_percentile(self): for probe, g in self.super_grids.items(): g_array = g.get_array() out_array = np.vectorize(self._percentile_grid)(g_array) self.super_grids[probe] = Grid.array_to_grid(out_array, g)
def _open_grid(self, g, probe): g_array = g.get_array().astype(int) opened_array = ndimage.binary_opening(g_array, structure=self.probe_selem_dict[probe]) return Grid.array_to_grid(opened_array.astype(int), g)
def _close_grid(self, g, probe): g_array = g.get_array().astype(int) closed_array = ndimage.binary_erosion(g_array, structure=self.probe_selem_dict[probe]) return Grid.array_to_grid(closed_array.astype(int), g)