-
Notifications
You must be signed in to change notification settings - Fork 3
API
main_window.py: BrightEyes-MCS - MainWindow.
class PluginSignals(QObject)Class for defining custom signals for the plugins
class MainWindow(QMainWindow)Main window class for the BrightEyes-MCS application.
Attributes:
-
http_server_threadFastAPIServerThread - Thread for the HTTP server. -
guiReadyFlagbool - Flag indicating if the GUI is ready. -
init_readybool - Flag indicating if the initialization is ready. -
splashQSplashScreen - Splash screen for the application.
@Slot()
def httpServerCheckBoxChanged()Slot for the HTTP server checkbox changed event
def httpApiServer_start()Starts the FastAPI HTTP server
def httpApiServer_stop()Stops the FastAPI HTTP server
def configuration_helper_init()Return a dictionary with the configuration helper for the GUI elements They are used both for configuration saving and loading, and macros.
def setupAnalogOutputGUI()Build the Analog Output GUI menu
@Slot()
def analogOutChanged()Slot for the Analog Output changed event
@Slot()
def laserChanged()Slot for the Laser changed event
@Slot()
def table_keyPressEvent(event)Slot for the table key pressed
@Slot()
def traceReset()Slot for the trace reset event It resets the time trace
@Slot()
def FCSReset()Slot for the FCS reset event.
@Slot()
def table_markers_keyPressEvent(event)Slot for the table of the markers when a key pressed It handles the delete key
@Slot()
def traceClicked(event)Slot for the time trace clicked event
@Slot()
def cmd_path_ttm()Slot for the TTM path command
@Slot()
def cmd_path_destinationfolder()Slot for the data destination folder command
@Slot()
def numberChannelsChanged()Slot for the number of channels changed event
@Slot()
def cmd_filename()Slot for selecting the filename
@Slot()
def cmd_moveToSelectedRowMarker()Slot for moving to the selected row marker
def moveToSelectedColumnFCS(k)Set the GUI configuration to the selected column in the Macro/FCS table
@Slot()
def cmd_moveToSelectedColumnFCS(k=None)Set the GUI configuration to the current column in the Macro/FCS table
@Slot()
def prova(ev)dummy button
@Slot()
def getTabWinMinimization(widget, event)Slot for the tab window minimization event
@Slot()
def tabDoubleClick(number)Slot for the tab double click event: it moves the tab to a new window
def guiReadyEvent()Slot for the GUI ready event, normally called when the GUI is ready to be used
@Slot()
def showEvent(event)Overridden showEvent method for generating the GUI ready event
def ask_to_save_cfg_as_permanent(file_cfg_nicer)Message box to ask if the configuration file should be saved as permanent
@Slot()
def bit_file_clicked()Slot for the selecting the bitfile of the 1st FPGA
@Slot()
def bit_file_clicked2()Slot for the selecting the bitfile of the 2nd FPGA
def checkDefaultCfg(default_name="cfg/current_system")Check if the default configuration file exists
def setNewDefaultCfg(default_cfg, default_name="cfg/current_system")Set a new default configuration file
def getGUI_data()Get the GUI data and return it as a dictionary
def setGUI_data(configuration={})Set the GUI data from a dictionary (it can be also a partial configuration)
@Slot()
def delete_list_file()delete the selected files in the list
@Slot()
def copy_list_file()Actually is "cut" the files ready to be "paste" in some folder
@Slot()
def cmd_load_plugin()Load the selected plugin
@Slot()
def cmd_close_plugin()Close the selected plugin
@Slot()
def cmd_update_plugin_list()Update the plugin list
@Slot()
def axesRangeChanged(ev=None)Slot for the axes range changed event, when the range of the axes of the Image Preview is changed
@Slot()
def closeEvent(event)Overridden closeEvent method for closing the application
def bitfile_check(path)Check if the bitfile exists
def connectFPGA()Connect to the FPGA(s)
def setRegistersDict(myconf)Set the registers dictionary which is mapped to the FPGA
@Slot()
def panoramaButton()Slot for the panorama button event It copy the current image to the panorama image place
def AutoRange_im_widget()Auto range the image widget
def updateRoiPanaorama()update the panorama ROI
def roiModified(event)roiModified event - DUMMY
def setSelectedChannel(ch)set the selected channel
@Slot()
def about()Show the about dialog box with license
def imageMoved(event)image moved event
def imageClicked(event)image clicked event. if the CTRL key is pressed, it will add a marker else it will center the image on the clicked point
def drawMarkers()draw the markers on the image
def fingerprintClicked(event)fingerprint clicked event
def update_fingerprint_mask()update the fingerprint mask
@Slot()
def radio_ttm_local()activate or disactivate the checkbox TTM in local mode
@Slot()
def radio_ttm_remote()activate or disactivate the checkbox TTM in remote mode
@Slot()
def selectedAutoscaleImg()Slot for the autoscale image checkbox
@Slot()
def selectedAutoscaleFingerprint()Slot for the autoscale fingerprint checkbox
@Slot()
def microimageType(num)Slot for the microimage type selection
@Slot()
def updateTables()Update the Status tables
@Slot()
def test1()dummy button clicked event for test
@Slot()
def test2()dummy button clicked event for test
@Slot()
def test3()dummy button clicked event for test
@Slot()
def test4()dummy button clicked event for test
@Slot()
def test5()dummy button clicked event for test
@Slot()
def test6()dummy button clicked event for test
@Slot()
def test7()dummy button clicked event for test
@Slot()
def test8()dummy button clicked event for test
def define_circular(circular_points)define the points for the circular scan
@Slot()
def test9()dummy button clicked event for test
@Slot()
def circularMotionActivateChanged()activate or disactivate the circular motion
def load_circular(ARRAY_SIZE=32)load the circular scan position to the FPGA registers
@Slot()
def addcurrentconfmacro()Slot for the add current configuration to the table for macros
@Slot()
def addcurrentconfmacrofcs()Slot for the add current configuration to the table for macros activating FCS preview and forcing to zero the range
@Slot()
def copyPositionsMarkers()copy the markers to the table for macros
@Slot()
def copyPositionsMarkersFCS()copy the markers to the table for macros activating FCS preview and forcing to zero the range
@Slot()
def startBatchFCS()start the batch event
@Slot()
def batchFCS()the actual loop for the batch event
@Slot()
def stopBatchFCS()stop the batch event
@Slot()
def timerConfigurationViewer_tick()timer tick event for the configuration viewer it set the status bar with the CPU and RAM usage
@Slot()
def markersViewTable()update the markers table
@Slot()
def timerPreviewImg_tick()timer tick event for the preview image continuosly update the preview image
def draw_fingerprint(data_finger_print, saturation_data)def openConsoleWidget()open the console widget
def microimage_analysis(data_finger_print)microimage analysis in live, useful for alligment
@Slot()
def temporalSettingsChanged()@Slot()
def checkBoxLockRatioChanged()lock the ratio of the ROI
@Slot()
def loadPreset()load the preset configuration
@Slot()
def savePreset()save the preset configuration
@Slot()
def calibrationFactorChanged()calibration factor changed event
@Slot()
def offset_V_Changed()offset in Volts changed event
@Slot()
def offset_um_Changed(force=False)offset in um changed event
@Slot()
def updatePixelValueChanged(number=None)update the number of pixel, line, frame changed event
@Slot()
def rangeValueChanged(number=None)the range in um is changed event
@Slot()
def offset_um_update(force=False)called when the offset in um is changed
@Slot()
def spatialSettingsChanged(force=False)spatial settings changed event
@Slot()
def positionSettingsChanged(force=False)position settings changed event
def positionSettingsChanged_apply(force=False)actuation of the position settings changed event
@Slot()
def DFD_clicked()activate the DFD mode
@Slot()
def updateMaxMinVoltages()event when the max and min voltages are changed
@Slot()
def plotSettingsChanged()@Slot()
def previewButtonClicked()preview button clicked event
@Slot()
def startButtonClicked()start button clicked event
@Slot()
def stopButtonClicked()stop button clicked event
def startAcquisition(activate_preview=False, do_run=True)the actual start acquisition function
@Slot()
def test_analog_digital()experimental mixed analog and digital mode
@Slot()
def trace_parameters_changed()trace parameters changed event
def configure_analog()configure the dictionary for the analog input
def activateShowPreview(enable)activate the preview mode
def activateFIFOflag()activate the FIFO flag
@Slot()
def grabPanorama()grab the panorama image
def updatePreviewConfiguration()update the preview configuration - channel selection
def defineFilename(with_folder=True)helper for define the filename of the data output
@Slot()
def start()start the acquisition
@Slot()
def ttm_activate_change_state()activate or deactivate the TTM
def ttm_remote_is_up()check if the TTM is up
@Slot()
def checkAlerts()check the GUI alerts i.e. potential wrong parameters
def previewLoop()the actual preview loop
def finalizeAcquisition()finalize the acquisition: save the data, add metadata, etc.
@Slot()
def cmd_filename_ttm()call the dialog for setting the filename for the TTM data receiver
def analog_before_stop()set the analog output to 0V before stopping the acquisition
def stopAcquisition()stop the acquisition
@Slot()
def stop()stop the acquisition clicked event
def sendCmdRun()send the run command to the FPGA
def sendCmdStop()send the stop command to the FPGA
def getPreviewImage(projection="xy", rgb=False)get the preview image
def getPreviewFlatData()get the preview flat data
def getCurrentPreviewImage(preview_img=None)get the current preview image
def plotPreviewImage(img=None)plot the preview image
def plotCurrentImage()plot the current image
@Slot()
def selectChannelSum()select the sum channel
@Slot()
def SaveConfigurationCmd()save the configuration clicked event
@Slot()
def SaveConfiguration()save the configuration to a .cfg file
@Slot()
def LoadConfigurationCmd()load the configuration clicked event
@Slot()
def LoadConfiguration(filecfg="")load the configuration from a .cfg file
def script_plot_fingerprint(fingerprint)plot the fingerprint, handle for scripts
def script_plot_shiftvector(sv=None)plot the shift vector, handle for scripts
class NumpyEncoder(json.JSONEncoder)helper class for encoding numpy arrays to json
Author: Luca Bega. Istituto Italiano di Tecnologia
class ConsoleWidget(RichJupyterWidget)def push_vars(variableDict)Given a dictionary containing name / value pairs, push those variables to the Jupyter console widget
def clear()Clears the terminal
def print_text(text)Prints some plain text to the console
def execute_command(command, hidden=False)Execute a command in the frame of the console widget
def showFLIM(intensity,
lifetime,
bounds_Tau=None,
bounds_Int=None,
satFactor=0.657,
outOfBoundsHue=0.8,
invertColormap=False,
fig=None)Display together the lifetime and intensity images with a proper colormap. Referring to the HSV color model: Intensity values are mapped in Value Lifetime values are mapped in Hue If the lifetime of a pixel is outside the interval [minInt, maxInt], that pixel is rendered with Hue outOfBoundsHue (default: violet)
Input parameters intensityIm: Pixel values are photon counts. lifetimeIm: Pixel values are lifetime values.
bounds_Tau minTau: minimum lifetime value of the colorbar maxTau: maximum lifetime value of the colorbar bounds_Int minInt: minimum intensity value of the colorbar maxInt: maximum intensity value of the colorbar invertColormap: (False) outOfBoundsHue: Hue to render the out of bounds pixels (0.8) satFactor: The span of the Hue space (0.657)
Last Modified May 2022 by Alessandro Zunino Based on the MATLAB function written by Giorgio Tortarolo
class TreeModel(QAbstractItemModel)def index(row, column, index=QModelIndex())Returns the index of the item in the model specified by the given row, column and parent index
def parent(index)Returns the parent of the model item with the given index If the item has no parent, an invalid QModelIndex is returned
def rowCount(index=QModelIndex())Returns the number of rows under the given parent When the parent is valid it means that rowCount is returning the number of children of parent
def columnCount(index=QModelIndex())Returns the number of columns for the children of the given parent
def data(index, role=Qt.DisplayRole)Returns the data stored under the given role for the item referred to by the index
def headerData(section, orientation, role=Qt.DisplayRole)Returns the data for the given role and section in the header with the specified orientation
class MemorySharedNumpyArray(object)A shared array (based on multiprocessing Array). Also, you can get a Numpy handle to the shared array with the get_numpy_handle() method. If you need the locking etc. capabilities of the mp.Array, you can access the data attribute directly.
Attributes:
-
datamp.Array - the shared array -
sampling- information about the physical spacing between elements (e.g. pixel size). The information will be the same for all array views. Make sure that when slicing, the dimensionality is appropriate. -
idstr - a unique identifier (tag) for an array instance. Makes dealing with array views a little bit more straightforward -
np_shapetuple - the shape of the array -
sizeint - the size of the flattened array -
np.dtypestr - the Numpy dtype string
def __init__(dtype, shape, sampling=0, lock=True)Arguments:
-
dtypestr - a Numpy data type string ('uint32' etc.). You can also use the constants defined in Numpy (np.uint32 etc.) -
shapetuple - the shape of the array (e.g. (20, 50, 200)) -
sampling- sampling info, e.g. tuple of pixel spacings in an image
Arguments:
-
lock- Apply a process lock.
def get_numpy_handle(reshape=True)Return a Numpy array handle to the shared array.
Returns:
-
np.ndarray- the array reshaped to the original shape definition
class Worker(QRunnable)Worker thread
Inherits from QRunnable to handler worker thread setup, signals and wrap-up.
Arguments:
-
callback(function): The function callback to run on this worker thread. Supplied args and kwargs will be passed through to the runner. -
args: Arguments to pass to the callback function -
kwargs: Keywords to pass to the callback function
@Slot()
def run()Initialise the runner function with passed args, kwargs.
class PluginsManager()Manages the plugins for the main window application.
Attributes:
-
main_windowQMainWindow - The main window of the application. -
plugin_instancesdict - Dictionary to store plugin instances. -
trigger_registerdict - Dictionary to store registered triggers.
def __init__(main_window)Initialize the PluginsManager.
Arguments:
-
main_windowQMainWindow - The main window of the application.
@Slot()
def signal_emitted(string)Slot to handle emitted signals.
Arguments:
-
stringstr - The emitted signal string.
def plugin_list()Get the list of available plugins.
Returns:
-
list- List of available plugins.
def plugin_loader(plugin_name)Load a plugin by name.
Arguments:
-
plugin_namestr - The name of the plugin to load.
def instances()Get the instances of loaded plugins.
Returns:
-
dict- Dictionary of plugin instances.
def addTab(widget, caption)Add a tab to the main window.
Arguments:
-
widgetQWidget - The widget to add as a tab. -
captionstr - The caption for the tab.
def register_trigger(trigger_name, func)Register a trigger with a function.
Arguments:
-
trigger_namestr - The name of the trigger. -
funccallable - The function to call when the trigger is emitted.
def print_dec(*objects, sep=" ", end="\n", file=sys.stdout, flush=False)A print "decorated": it add information about line and the file in which this command is called
class DataPreProcess(mp.Process)def __init__(queue_in,
dict_of_shared_loc,
last_preprocessed_len,
dict_of_queue_array_out,
dict_of_dtype_queue_array_out,
len_buffer=0,
debug=False,
use_rust_fifo=True)Arguments:
-
queue_in: this is the queue from the fpgahandleprocess each elements contains ["FIFONAME", data] -
dict_of_shared_loc: {'FIFONAME':shared_loc_fifo,...} -
dict_of_queue_array_out: {'FIFONAME':shared_queue_array_out,...} -
dict_of_dtype_queue_array_out: {'FIFONAME':dtype_shared_queue_array_out,...}
class NumpyEncoder(json.JSONEncoder)Custom JSON encoder for NumPy arrays
class FastAPIServerThread(threading.Thread)Thread class for running the FastAPI server
def __init__(main_window, host="127.0.0.1", port=8000)Constructor for the FastAPIServerThread class that initializes the FastAPI app and the server configuration parameters (host and port)
def run()Method to run the FastAPI server
def stop()Method to stop the FastAPI server
class SpadFcsManager(QObject)Manages the SPAD FCS (Single-Photon Avalanche Diode Fluorescence Correlation Spectroscopy) operations, including FPGA connections, data acquisition, and processing.
Attributes:
-
channelsint - Number of channels. -
dim_detectorint - Dimension of the detector. -
niAddrstr - NI address. -
bitfilestr - Path to the bitfile. -
timeout_fifosfloat - Timeout for the FIFOs. -
fpga_handleFpgaHandle - Handle for the FPGA. -
shared_arrays_readybool - Flag indicating if shared arrays are ready. -
mp_managermultiprocessing.Manager - Manager for multiprocessing. -
ultra_dict_instdict - Dictionary for ultra configuration. -
shared_dictdict - Shared dictionary for multiprocessing. -
default_configurationdict - Default configuration for the registers. -
requested_depthint - Requested depth for acquisition. -
actual_depthint - Actual depth for acquisition. -
timebins_per_pixelint - Number of time bins per pixel. -
time_resolutionfloat - Time resolution. -
dim_xint - Number of pixels in x dimension. -
dim_yint - Number of pixels in y dimension. -
dim_zint - Number of frames. -
dim_repint - Number of repetitions. -
previewProcessAcquisitionLoopProcess - Process for previewing data. -
expected_raw_dataint - Expected raw data. -
expected_raw_data_per_frameint - Expected raw data per frame. -
registers_configurationdict - Configuration of the registers. -
shared_memory_bufferMemorySharedNumpyArray - Shared memory buffer. -
shared_image_xyMemorySharedNumpyArray - Shared image in xy plane. -
shared_fingerprintMemorySharedNumpyArray - Shared fingerprint data. -
shared_fingerprint_maskMemorySharedNumpyArray - Shared fingerprint mask. -
is_connectedbool - Flag indicating if connected to FPGA. -
fifo_chuck_sizeint - Size of the FIFO chuck. -
acquisition_done_eventmultiprocessing.Event - Event for acquisition done. -
acquisition_almost_done_eventmultiprocessing.Event - Event for acquisition almost done. -
acquisition_run_eventmultiprocessing.Event - Event for acquisition run. -
acquisition_stop_eventmultiprocessing.Event - Event for acquisition stop. -
activate_preview_eventmultiprocessing.Event - Event for activating preview. -
autocorrelation_maxxint - Maximum value for autocorrelation. -
trace_binsint - Number of trace bins. -
trace_sample_per_binsint - Number of samples per trace bin. -
preview_buffer_size_in_wordsint - Size of the preview buffer in words. -
len_fifo_prebufferint - Length of the FIFO prebuffer. -
activated_fifos_listlist - List of activated FIFOs. -
DFD_Activatebool - Flag for DFD activation. -
snake_walkbool - Flag for snake walk mode. -
use_rust_fifobool - Flag for using Rust FIFO. -
debugbool - Debug flag.
def __init__(filename="bitfiles/MyBitfileUSB.lvbitx",
address="RIO0",
channels=25)Constructor of the class of SpaFCSManager
def __del__()Destructor of the class
def set_channels(ch)Set the number of channels
def activateShowPreview(enable)Activate the preview flag
def setActivatedFifo(fifos_list)Set the activated FIFOs
def acquisition_stop()Stop the acquisition
def acquisition_run()Run the acquisition
def acquisition_done_reset()Reset the acquisition done event
def acquisition_almost_done_reset()Reset the acquisition almost done event
def acquisition_is_done()Check if the acquisition is done
def acquisition_is_almost_done()Check if the acquisition is almost done
def set_activate_preview(active=True)Activate the preview
def set_activate_DFD(activate=True)Activate the DFD mode
def set_activate_snake_walk(activate=True)Set the snake walk (bidirectional scanning)
def set_bit_file(bitfile="")Set the bit file for the 1st FPGA
def set_ni_addr(niAddr="")Set the NI address for the 1st FPGA
def set_bit_file_second_fpga(bitfile="")Set the bit file for the 2nd FPGA
def set_ni_addr_second_fpga(niAddr="")Set the NI address for the 2nd FPGA
def set_preview_buffer_size_in_words(preview_buffer_size_in_words)Set the preview buffer size in words
def set_len_fifo_prebuffer(len_fifo_prebuffer)Set the length of the FIFO prebuffer
def set_timeout_fifos(timeout)Set the timeout for the FIFOs
def connect(initial_registers={}, list_fifos=[])Connect to the FPGA using FPGA handle class
def set_filename_h5(filename)Set the filename for the HDF5 file
def set_fingerprint_mask(fingerprint_mask)Set the fingerprint mask
def set_use_rust_fifo(value=True)Set the use of rust FIFO
def run()Run the FPGA, start the data process, the preview process and run the FPGA handle class
def previewProcess_isAlive()Preview process is alive
def dataProcess_isAlive()dataProcess is alive
def freeMemory()Free the memory
def setRegistersDict(myconf)Set the registers dictionary
def readRegistersDict()Read the registers dictionary
def update_chuck()Update the chuck size
def getCurrentPreviewElement(fifo_name="FIFO")Get the current preview element
def getCurrentAcquistionElement(fifo_name="FIFO")Get the current acquisition element
def getLastPreprocessedLen(fifo_name="FIFO")Get the last preprocessed length
def getExpectedFifoElements()Get the expected FIFO elements
def getExpectedFifoElementsPerFrame()Get the expected FIFO elements per frame
def stopFPGA()stop the FPGA
def stopAcquisition()Stop the acquisition
def stopPreview()Stop the preview
def get_current_z()Get the current z
def get_current_rep()Get the current repetition
def get_total_photon()Get the number of total photon
def get_number_of_threads_h5()Get the number of threads
def reset()Reset the FPGA
def getFingerprint()Get the fingerprint
def getFingerprintCumulative()Get the fingerprint cumulative
def getFingerprintCumulativeLast10000()Get the fingerprint cumulative last 10000 data packets
def getFingerprintCumulativeLastFrame()Get the fingerprint cumulative last frame
def getFingerprintSaturation()Get the fingerprint saturation
def getImage()Get the image
def setSelectedChannel(ch)Set the selected channel
def set_autocorrelation_maxx(value=20)Set the autocorrelation maxx
def set_trace_bins(trace_bins=30000)Set the trace bins
def set_trace_sample_per_bins(trace_sample_per_bins=10000)Set the trace sample per bins
def getAutocorrelation()Get the autocorrelation
def getTrace()Get the trace
def getPreviewImage(projection="xy", rgb=False)Get the preview image with at selected projection
def getPreviewFlatData(frame=0, channel=10)Get the preview flat data
def get_registers_configuration()Get the registers configuration
def update_shared_dict(ndict={})Update the shared dictionary
def read_shared_dict()Read the shared dictionary
def get_FIFO_status()Get the status of the FIFO
def trace_reset()Reset the trace process
def FCS_reset()Reset the FCS process
The load_plugin.py is the default loader of the plugin that can be modified in order to implement the plugin. Remind to add from .load_plugin import load_plugin in the init.py
The load_plugin.py is the default loader of the plugin that can be modified in order to implement the plugin. Remind to add from .load_plugin import load_plugin in the init.py The parameter plugin_manager allows to QWidget to the plugins plugin_manager.addTab(context["widget"], "myplugin")
class myForm(Ui_Form)An example of implementation of the QWidget used by the plugin
The load_plugin.py is the default loader of the plugin that can be modified in order to implement the plugin. Remind to add from .load_plugin import load_plugin in the init.py The parameter plugin_manager allows to QWidget to the plugins plugin_manager.addTab(context["widget"], "myplugin")
An example of implementation of the QWidget used by the plugin This script is can run also as stand-alone form.
class myForm(Ui_Form, QWidget)An example of implementation of the QWidget used by the plugin
Script that can be launched directly on the ScriptLauncher. Calculate and shows the FSC correlation of the last data acquired.
s
'resolution' of the correlation function: the higher this number, the more lag times are used
start index to fit the data, set to 15-30 to remove the afterpulse component at short lag times
parameters to fit
minimum values for the parameters
maximum values for the parameters
shape factor, i.e. z0/w0 with z0 the height of the PSF and w0 the width (1/e^2 radius of the intensity)
start values for the fit
used for the color of the output plot
start values for the fit
start values for the fit
from circFCS 2021-11-25
Script that can be launched directly on the ScriptLauncher. This script can be used with by using a grid sample It calculates the distances between the grid cell, and it is useful to perform calculate the calibration factor of the positioner (galvo mirror)
um/V
um/V
px/V
px/V
2000
um
Script that can be launched directly on the ScriptLauncher. This script calculate and shows the shift vector of the last ascquired image.
np.squeeze(data)
def build_cython_with_vs()Builds the Cython part of the code using Visual Studio (MSVC).
def build_cython_with_msys2(msys2_path)Builds the Cython part of the code using MSYS2 (mingw32).
This is where the shortcut will be created
directory to which the shortcut is created
This is where the shortcut will be created