def callZoomToValue(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() # Get the current zoom value old_zoom = self.parent.imageTabDisplay.displayedTabs[ tab_id].image_class.zoom # Get the user input new_zoom, is_ok = qtw.QInputDialog.getDouble( self.parent, 'Set Zoom', 'Set the zoom to (%):', value=old_zoom * 100, min=0, decimals=2) # Edit the zoom if is_ok: self.parent.imageTabDisplay.changeZoom(new_zoom=new_zoom / 100, tab_id=tab_id) else: errorMessageNoImage()
def saveTrajectoryFile(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Retrieve the current tab ID tab_id = self.parent.imageTabDisplay.currentIndex() crt_traj = self.parent.imageTabDisplay.displayedTabs[ tab_id].image_class.trajectory # Save the trajectory in a file if crt_traj is not None: # Get the file name trajectory_file, _ = qtw.QFileDialog.getSaveFileName( self.parent, "Save Trajectory...", "", "Hierarchical Data (*.xml);;Comma-Separated Value (*.csv)") if trajectory_file != "": crt_traj.save(file_name=trajectory_file) # Display message if there are no trajectory opened else: errorMessage( "No Trajectory", "There is no loaded trajectory to be saved in a file.") else: errorMessageNoImage()
def callDarkToBright(self): # Check if a tab is open if len( self.parent.imageTabDisplay.displayedTabs ) > 0: openWindow(self.parent, darkToBrightCorrectionWindow, 'dark_to_bright') else: errorMessageNoImage()
def callRenameCurrentTab(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() # Rename the current tab self.parent.imageTabDisplay.renameTab(tab_id) else: errorMessageNoImage()
def callZoomBack(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() # Reset the zoom self.parent.imageTabDisplay.changeZoom(new_zoom=1, tab_id=tab_id) else: errorMessageNoImage()
def callZoomInOutCurrentTab(self, dezoom=False): # Check if a tab is open if len( self.parent.imageTabDisplay.displayedTabs ) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() # Modify the zoom self.parent.imageTabDisplay.changeZoom(dezoom=dezoom, tab_id=tab_id) else: errorMessageNoImage()
def callZoomToFit(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() # Reset the zoom self.parent.imageTabDisplay.zoomToFitFrame(tab_id=tab_id) else: errorMessageNoImage()
def callBrightnessCorrection(self): # Check if a tab is open if len( self.parent.imageTabDisplay.displayedTabs ) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[tab_id].image_class # Open the window openWindow(self.parent, contrastCorrectionWindow, 'contrast_correction', image_class=crt_class) else: errorMessageNoImage()
def callCropCurrentImage(self): # Check if a tab is open if len( self.parent.imageTabDisplay.displayedTabs ) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[tab_id].image_class # Open the window openWindow(self.parent, imageCropWindow, 'crop_image', image_class=crt_class) else: errorMessageNoImage()
def callCloseAllTabs(self): # Get the number of tabs opened n_tabs = len(self.parent.imageTabDisplay.displayedTabs) # Check if a tab is open if n_tabs > 0: # Close all the tabs for tab_id in range(n_tabs - 1, -1, -1): self.parent.imageTabDisplay.closeTab(tab_id) else: errorMessageNoImage()
def callSaveSingleFrame(self): # Check if a tab is open if len( self.parent.imageTabDisplay.displayedTabs ) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[tab_id].image_class # Open the save window openWindow(self.parent, saveSingleImageWindow, 'save_single', image_class=crt_class) else: errorMessageNoImage()
def callSetScaleWindow(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[ tab_id].image_class # Call the window openWindow(self.parent, SetScaleWindow, 'set_scale', image_class=crt_class) else: errorMessageNoImage()
def callParticleDetectionWindow(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[ tab_id].image_class # Call the window openWindow(self.parent, particleDetectionWindow, 'particle_analysis', image_class=crt_class) else: errorMessageNoImage()
def callLoadTrajectory(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Open the load file browser trajectoryFile, _ = qtw.QFileDialog.getOpenFileName( self.parent, "Load Trajectory File...", "", "Hierarchical Data (*.xml);;All Files (*)") # Retrieve the current tab ID tab_id = self.parent.imageTabDisplay.currentIndex() # Load the trajectory in the session if trajectoryFile != "": self.parent.imageTabDisplay.displayedTabs[ tab_id].image_class.trajectory = startManager( trajectoryFile) # Check that the length matches n_traj = len( self.parent.imageTabDisplay.displayedTabs[tab_id]. image_class.trajectory.positions['frame'].unique()) n_frames = self.parent.imageTabDisplay.displayedTabs[ tab_id].image_class.n_frames # Display a warning if n_traj != n_frames: warningMessage( "Different Number of Frames", "The number of frames in the image stack and the number of frames in the trajectory do not match. This could lead to issues for displaying the positions of the particles." ) # Open the trajectory side bar self.callTrajectoryManagerDock() # Refresh the display self.parent.imageTabDisplay.displayedTabs[ tab_id].refreshPathList() self.parent.imageTabDisplay.displayedTabs[tab_id].displayImage( ) else: errorMessageNoImage()
def callIntensityFluctuations(self): # Check if a tab is open if len( self.parent.imageTabDisplay.displayedTabs ) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[tab_id].image_class n_frames = crt_class.n_frames # Check if there is more than one image in the stack if n_frames > 1: openWindow(self.parent, fluctuationCorrectionWindow, 'fluctuations_correction', image_array=crt_class.image.source) else: errorMessageNoStack() else: errorMessageNoImage()
def callFrameAveraging(self): # Check if a tab is open if len( self.parent.imageTabDisplay.displayedTabs ) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[tab_id].image_class n_frames = crt_class.n_frames # Check if there is more than one image in the stack if n_frames > 1: openWindow(self.parent, frameAveragingWindow, 'frame_average', image_array=crt_class.image.source) else: errorMessageNoStack() else: errorMessageNoImage()
def callMakeSubstack(self): # Check if a tab is open if len( self.parent.imageTabDisplay.displayedTabs ) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[tab_id].image_class n_frames = crt_class.n_frames # Check if there is more than one image in the stack if n_frames > 1: # Duplicate the current tab self.parent.imageTabDisplay.substackTab(tab_id) else: errorMessageNoStack() else: errorMessageNoImage()
def callSaveVideo(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[ tab_id].image_class n_frames = crt_class.n_frames # Check if there is more than one image in the stack if n_frames > 1: #openWindow(self.parent, saveVideoWindow, 'save_frame', image_class=crt_class) pass else: errorMessageNoStack() else: errorMessageNoImage()
def callCenterCropWindow(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[ tab_id].image_class # Check if there is a trajectory if crt_class.trajectory is not None: # Get the selection from the dock if self.parent.docks["tracking"] is not None: _path_id = self.parent.docks[ "tracking"].pathSelectionEntry.comboBox.currentText() else: _path_id = 'All' # Prompt the user if a specific path is not selected is_ok = True if _path_id == 'All': path_list = crt_class.trajectory.listTracks().astype(str) _path_id, is_ok = qtw.QInputDialog.getItem( self.parent, 'Path Selection', 'Path to Center on:', path_list, 0, False) if is_ok: openWindow(self.parent, cropCenterWindow, 'crop_center', image_class=crt_class, path_id=int(_path_id)) else: errorMessageNoTrajectory() else: errorMessageNoImage()
def callSignalAnalysisWindow(self): # Check if a tab is open if len(self.parent.imageTabDisplay.displayedTabs) > 0: # Get the current tab tab_id = self.parent.imageTabDisplay.currentIndex() crt_class = self.parent.imageTabDisplay.displayedTabs[ tab_id].image_class # Check if there is a trajectory if crt_class.trajectory is not None: openWindow(self.parent, analyseSignalWindow, 'measure_signals', image_class=crt_class) else: errorMessageNoTrajectory() else: errorMessageNoImage()