def plot_peak_ids(self): """Overlays id numbers for identified peaks on an average image of the stack. Identified peaks are either those you specified as target_locations, or if not specified, those automatically identified from the average image. Use this function to identify a peak to overlay a characteristic of onto the original experimental image using the plot_image_overlay function. """ f = plt.figure() imgavg = np.average(self.data, axis=2) plt.imshow(imgavg) plt.gray() if self.target_locations is None: # identify the peaks on the average image if self.peak_width is None: self.peak_width = 10 self.target_locations = pc.peak_attribs_image( imgavg, self.peak_width)[:, :2] # plot the peak labels for pk_id in xrange(self.target_locations.shape[0]): plt.text(self.target_locations[pk_id, 0], self.target_locations[pk_id, 1], "%s" % pk_id, size=10, rotation=0., ha="center", va="center", bbox=dict( boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8), )) return f
def plot_peak_ids(self): """Overlays id numbers for identified peaks on an average image of the stack. Identified peaks are either those you specified as target_locations, or if not specified, those automatically identified from the average image. Use this function to identify a peak to overlay a characteristic of onto the original experimental image using the plot_image_overlay function. """ f=plt.figure() imgavg=np.average(self.data,axis=2) plt.imshow(imgavg) plt.gray() if self.target_locations is None: # identify the peaks on the average image if self.peak_width is None: self.peak_width=10 self.target_locations=pc.peak_attribs_image(imgavg, self.peak_width)[:,:2] # plot the peak labels for pk_id in xrange(self.target_locations.shape[0]): plt.text(self.target_locations[pk_id,0], self.target_locations[pk_id,1], "%s"%pk_id, size=10, rotation=0., ha="center", va="center", bbox = dict(boxstyle="round", ec=(1., 0.5, 0.5), fc=(1., 0.8, 0.8), ) ) return f
def plot_cell_peak_overlays(self, plot_component=None, mva_type='PCA', peak_mva=True, plot_shifts=True, plot_char=None): """Overlays peak characteristics on an image plot of the average image. Only appropriate for Image objects that consist of 3D stacks of cropped data. Parameters: plot_component - None or int The integer index of the component to plot scores for. If specified, the values plotted for the shifts (if enabled by the plot_shifts flag) and the values plotted for the plot characteristics (if enabled by the plot_char flag) will be drawn from the given component resulting from MVA on the peak characteristics. NOTE: only makes sense right now for examining results of MVA on peak characteristics, NOT MVA results on the images themselves (factor images). mva_type - str, 'PCA' or 'ICA', case insensitive. default is 'PCA' Choose between the components that will be used for plotting component maps. Note that whichever analysis you choose here has to actually have already been performed. peak_mva - bool, default is True If True, draws the information to be plotted from the mva results derived from peak characteristics. If False, does the following with Factor images: - Reconstructs the data using all available components - locates peaks on all images in reconstructed data - reconstructs the data using all components EXCEPT the component specified by the plot_component parameter - locates peaks on all images in reconstructed data - subtracts the peak characteristics of the first (complete) data from the data without the component included. This difference data is what gets plotted. plot_shifts - bool, default is True If true, plots a quiver (arrow) plot showing the shifts for each peak present in the component being plotted. plot_char - None or int If int, the id of the characteristic to plot as the colored scatter plot. Possible components are: 4: peak height 5: peak orientation 6: peak eccentricity """ f = plt.figure() imgavg = np.average(self.data, axis=2) if self.target_locations is None: # identify the peaks on the average image if self.peak_width is None: self.peak_width = 10 self.target_locations = pc.peak_attribs_image( imgavg, self.peak_width)[:, :2] stl = self.target_locations shifts = np.zeros((stl.shape[0], 2)) char = np.zeros(stl.shape[0]) if plot_component is not None: # get the mva_results (components) for the peaks if mva_type.upper() == 'PCA': component = self.peak_mva_results.pc[:, plot_component] elif mva_type.upper() == 'ICA': component = self.peak_mva_results.ic[:, plot_component] for pos in xrange(stl.shape[0]): shifts[pos] = component[pos * 7 + 2:pos * 7 + 4] if plot_char: char[pos] = component[pos * 7 + plot_char] plt.imshow(imgavg) plt.gray() if plot_shifts: plt.quiver(stl[:, 0], stl[:, 1], shifts[:, 0], shifts[:, 1], units='xy', color='white') if plot_char is not None: plt.scatter(stl[:, 0], stl[:, 1], c=char) plt.jet() plt.colorbar() return f
def plot_cell_peak_overlays(self, plot_component=None, mva_type='PCA', peak_mva=True, plot_shifts=True, plot_char=None): """Overlays peak characteristics on an image plot of the average image. Only appropriate for Image objects that consist of 3D stacks of cropped data. Parameters: plot_component - None or int The integer index of the component to plot scores for. If specified, the values plotted for the shifts (if enabled by the plot_shifts flag) and the values plotted for the plot characteristics (if enabled by the plot_char flag) will be drawn from the given component resulting from MVA on the peak characteristics. NOTE: only makes sense right now for examining results of MVA on peak characteristics, NOT MVA results on the images themselves (factor images). mva_type - str, 'PCA' or 'ICA', case insensitive. default is 'PCA' Choose between the components that will be used for plotting component maps. Note that whichever analysis you choose here has to actually have already been performed. peak_mva - bool, default is True If True, draws the information to be plotted from the mva results derived from peak characteristics. If False, does the following with Factor images: - Reconstructs the data using all available components - locates peaks on all images in reconstructed data - reconstructs the data using all components EXCEPT the component specified by the plot_component parameter - locates peaks on all images in reconstructed data - subtracts the peak characteristics of the first (complete) data from the data without the component included. This difference data is what gets plotted. plot_shifts - bool, default is True If true, plots a quiver (arrow) plot showing the shifts for each peak present in the component being plotted. plot_char - None or int If int, the id of the characteristic to plot as the colored scatter plot. Possible components are: 4: peak height 5: peak orientation 6: peak eccentricity """ f=plt.figure() imgavg=np.average(self.data,axis=2) if self.target_locations is None: # identify the peaks on the average image if self.peak_width is None: self.peak_width=10 self.target_locations=pc.peak_attribs_image(imgavg, self.peak_width)[:,:2] stl=self.target_locations shifts=np.zeros((stl.shape[0],2)) char=np.zeros(stl.shape[0]) if plot_component is not None: # get the mva_results (components) for the peaks if mva_type.upper()=='PCA': component=self.peak_mva_results.pc[:,plot_component] elif mva_type.upper()=='ICA': component=self.peak_mva_results.ic[:,plot_component] for pos in xrange(stl.shape[0]): shifts[pos]=component[pos*7+2:pos*7+4] if plot_char: char[pos]=component[pos*7+plot_char] plt.imshow(imgavg) plt.gray() if plot_shifts: plt.quiver(stl[:,0],stl[:,1], shifts[:,0], shifts[:,1], units='xy', color='white' ) if plot_char is not None : plt.scatter(stl[:,0],stl[:,1],c=char) plt.jet() plt.colorbar() return f