populse_mia.user_interface.data_browser package¶
Handle the data browser tab. Visualize, modify and search data.
- Contains:
- Module:
advanced_search
count_table
data_browser
mini_viewer
modify_table
rapid_search
Submodules¶
populse_mia.user_interface.data_browser.advanced_search module¶
Module to define the advanced search.
- Contains:
- Class:
AdvancedSearch
- class populse_mia.user_interface.data_browser.advanced_search.AdvancedSearch(project, data_browser, scans_list=None, tags_list=None, from_pipeline=False)[source]¶
Bases:
QWidget
Class that manages the widget of the advanced search
The advanced search creates a complex query to the database and is a combination of several “query lines” which are linked with AND or OR and all composed of: - A negation or not - A tag name or all visible tags - A condition (==, !=, >, <, >=, <=, CONTAINS, IN, BETWEEN) - A value
- __init__(project, data_browser, scans_list=None, tags_list=None, from_pipeline=False)[source]¶
Initialization of the AdvancedSearch class.
- Parameters:
project – current project in the software
data_browser – parent data browser widget
scans_list – current list of the documents
tags_list – list of the visualized tags
from_pipeline – True if the widget is called from the pipeline manager
- apply_filter(filter)[source]¶
Applies a filter to update the table data by refining the displayed scans based on the filter criteria. The filter is used to query documents from the database, and the results are reflected in the data browser.
This function handles the following tasks: - Retrieves filter parameters (e.g., conditions, values, links)
from the provided filter object.
Updates the table rows based on the filter values, including conditions and fields.
Prepares and applies the filter query to the database to fetch relevant results.
If the filter is successfully applied, updates the table data with the filtered results.
If an error occurs during the filtering process, displays a warning message and reverts to the full set of scans.
- Parameters:
filter – A filter object that contains the criteria (e.g., conditions, values, and fields) to apply when querying the database. The filter is applied to update the visible scans in the table.
- displayConditionRules(field, condition)[source]¶
Updates the available condition choices based on the field’s tag type.
This function adjusts the list of conditions (e.g., <, >, BETWEEN, IN) available in the condition widget, depending on the type of the tag selected in the field widget. Certain conditions are removed or added based on the tag’s field type, and the condition choices are sorted afterward.
The rules for updating the condition choices are as follows: - For tags with a field type of list, string, or boolean, or if
the tag name is “All visualized tags”, certain operators like <, >, <=, >=, and BETWEEN are removed.
If the tag’s field type is compatible with numeric comparisons (i.e., not list, string, or boolean), operators like <, >, <=, >=, and BETWEEN are added.
If the tag is a list, the “IN” condition is removed.
Otherwise, the “IN” condition is added.
- Parameters:
field – The field widget representing the selected tag. Used to determine the tag type and adjust the condition choices accordingly.
condition – The condition widget where the available conditions are updated based on the tag type.
- displayValueRules(choice, value)[source]¶
Update the placeholder text and the enabled/disabled state of the value input based on the selected condition choice.
This function adjusts the value widget’s state (enabled/disabled) and its placeholder text depending on the condition selected in the choice widget.
The rules are as follows: - “BETWEEN”: Enables the value input and sets a placeholder text
asking the user to separate the two inclusive borders with a semicolon and a space.
- “IN”: Enables the value input and sets a placeholder text asking
the user to separate each list item with a semicolon and a space.
- “HAS VALUE” or “HAS NO VALUE”: Disables the value input and
clears any placeholder text or value.
- For all other conditions: Enables the value input and clears the
placeholder text.
- Parameters:
choice – The choice widget, which determines the selected condition.
value – The value widget, which represents the input field whose state will be updated.
- get_filters(replace_all_by_fields)[source]¶
Get the filters in a list.
- Parameters:
replace_all_by_fields – to replace All visualized tags by the list of visible fields
- Returns:
Lists of filters (fields, conditions, values, links, nots)
- static prepare_filters(links, fields, conditions, values, nots, scans)[source]¶
Prepare the str representation of the filter.
- Parameters:
links – list of links (AND/OR)
fields – list of fields
conditions – list of conditions (==, !=, <, >, <=, >=, IN, BETWEEN, CONTAINS, HAS VALUE, HAS NO VALUE)
values – list of values
nots – list of negations (”” or NOT)
scans – list of scans to search in
- Returns:
str representation of the filter
populse_mia.user_interface.data_browser.count_table module¶
This module provides a tool designed to verify and visualize the presence of scans in a project based on selected tags. It allows users to dynamically add and remove tags, and it displays the results in a table format, indicating the presence or absence of scans with green plus or red cross icons, respectively.
Key Features: - Dynamic tag selection and visualization. - Automatic table generation based on tag combinations. - Clear visual indicators for scan presence or absence. - Integration with a project’s scan data for real-time verification.
- Contains:
- Class:
CountTable
- class populse_mia.user_interface.data_browser.count_table.CountTable(project)[source]¶
Bases:
QDialog
Tool to verify the scans of a project by visualizing combinations of tags.
This tool allows users to select tags and visualize their combinations in a table format. It is composed of push buttons on its top, each one corresponding to a tag selected by the user. When, the “Count scans” button is clicked, a table is created with all the combinations possible for the values of the first n-1 tags. Then, the m values that can take the last tag are displayed in the header of the m last columns of the table. The cells are then filled with a green plus or a red cross depending on if there is at least a scan that has all the tags values or not.
- Example:
Assume that the current project has scans for two patients (P1 and P2) and three time points (T1, T2 and T3). For each (patient, time point), several sequences have been made (two RARE, one MDEFT and one FLASH). Selecting [PatientName, TimePoint, SequenceName] as tags, the table will be:
PatientName
TimePoint
RARE
MDEFT
FLASH
P1
T1
v(2)
v(1)
v(1)
P1
T2
v(2)
v(1)
v(1)
P1
T3
v(2)
v(1)
v(1)
P2
T1
v(2)
v(1)
v(1)
P2
T2
v(2)
v(1)
v(1)
P2
T3
v(2)
v(1)
v(1)
with v(n) meaning that n scans corresponds of the selected values for (PatientName, TimePoint,SequenceName).
If no scans corresponds for a triplet value, a red cross will be displayed. For example, if the user forgets to import one RARE for P1 at T2 and one FLASH for P2 at T3. The table will be:
PatientName
TimePoint
RARE
MDEFT
FLASH
P1
T1
v(2)
v(1)
v(1)
P1
T2
v(1)
v(1)
v(1)
P1
T3
v(2)
v(1)
v(1)
P2
T1
v(2)
v(1)
v(1)
P2
T2
v(2)
v(1)
v(1)
P2
T3
v(2)
v(1)
x
Thus, thanks to the CountTable tool, he or she directly knows if some scans are missing.
- __init__(project)[source]¶
Initialize the CountTable with the given project.
- Parameters:
project – The current project in the software.
- fill_values(idx)[source]¶
Fill values_list depending on the visualized tags
- Parameters:
idx – index of the select tag
populse_mia.user_interface.data_browser.data_browser module¶
Module to define data browser tab appearance, settings and methods.
- Contains:
- Class:
DataBrowser
DateFormatDelegate
DateTimeFormatDelegate
NumberFormatDelegate
TableDataBrowser
TimeFormatDelegate
- class populse_mia.user_interface.data_browser.data_browser.DataBrowser(project, main_window)[source]¶
Bases:
QWidget
Widget that contains everything in the Data Browser tab.
- Parameters:
project – current project in the software
main_window – main window of the software
- __init__(project, main_window)[source]¶
Initialization of the data_browser class
- Parameters:
project – current project in the software
main_window – main window of the software
- add_tag_infos(new_tag_name, new_default_value, tag_type, new_tag_description, new_tag_unit)[source]¶
Add the tag after add tag pop-up.
- Parameters:
new_tag_name – New tag name
new_default_value – New default value
tag_type – New tag type
new_tag_description – New tag description
new_tag_unit – New tag unit
- clone_tag_infos(tag_to_clone, new_tag_name)[source]¶
Clone the tag after the clone tag pop-up.
- Parameters:
tag_to_clone – Tag to clone
new_tag_name – New tag name
- remove_tag_infos(tag_names_to_remove)[source]¶
Remove user tags after the pop-up.
- Parameters:
tag_names_to_remove – list of tags to remove
- class populse_mia.user_interface.data_browser.data_browser.DateFormatDelegate(parent=None)[source]¶
Bases:
QItemDelegate
Delegate that is used to handle dates in the TableDataBrowser.
- class populse_mia.user_interface.data_browser.data_browser.DateTimeFormatDelegate(parent=None)[source]¶
Bases:
QItemDelegate
Delegate that is used to handle date & time in the TableDataBrowser.
- class populse_mia.user_interface.data_browser.data_browser.NumberFormatDelegate(parent=None)[source]¶
Bases:
QItemDelegate
Delegate that is used to handle numbers in the TableDataBrowser.
- class populse_mia.user_interface.data_browser.data_browser.TableDataBrowser(project, data_browser, tags_to_display, update_values, activate_selection, link_viewer=True)[source]¶
Bases:
QTableWidget
Table widget that displays the documents contained in the database and their associated tags.
- __init__(project, data_browser, tags_to_display, update_values, activate_selection, link_viewer=True)[source]¶
Initialization of the class
- Parameters:
project – current project in the software
data_browser – parent data browser widget
tags_to_display – list of tags to display
update_values – boolean to specify if edition is enabled
activate_selection – dictionary containing information about the processes that has been run to generate documents
link_viewer – boolean to specify if the table is linked to a viewer
- add_column(column, tag)[source]¶
Add a column to the table
- Parameters:
column – index of the column to add
tag – tag name to add
- add_rows(rows)[source]¶
Insert rows if they are not already in the table.
- Parameters:
rows – list of all scans
- change_cell_color(item_origin)[source]¶
Change the background color and the value of cells when edited by the user. Handle the multi-selection case.
- Parameters:
item_origin – item from where the call comes from
Create the context menu of the table.
- Parameters:
position – position of the mouse cursor
- delete_from_brick(name)[source]¶
Delete a document from its brick id.
This method is used to clean the database when the user initializes a pipeline (multiple bricks) but doesn’t run it before initializing another one or closing the software.
- Parameters:
name – string of the brick id
- fill_headers(take_tags_to_update=False)[source]¶
Initialize and fill the headers of the table.
- Parameters:
take_tags_to_update – boolean to hide or show tags
- get_current_filter()[source]¶
Get the current data browser selection (list of paths).
If there is a current selection, the list of selected scans is returned otherwise the list of the visible paths in the data browser is returned.
- Returns:
the list of scans corresponding to the current selection in the data browser
- get_index_insertion(to_insert)[source]¶
Get index insertion of a new column, since it’s already sorted in alphabetical order.
- Parameters:
to_insert – tag to insert
- get_scan_row(scan)[source]¶
Return the row index of the scan.
- Parameters:
scan – scan filename
- Returns:
index of the row of the scan
- get_tag_column(tag)[source]¶
Return the column index of the tag.
- Parameters:
tag – tag name
- Returns:
index of the column of the tag
- multiple_sort_infos(list_tags, order)[source]¶
Sort the table according to the tags specify in list_tags.
- Parameters:
list_tags – list of the tags on which to sort the documents
order – “Ascending” or “Descending”
- section_moved(logical_index, old_index, new_index)[source]¶
Update the visual index and forbid to move the first column when the user try to move columns.
- Parameters:
logical_index – int of the column logical index
old_index – int of the column old visual index
new_index – int of the column new visual index
- select_all_column(col)[source]¶
Select all column when the header is double clicked
- Parameters:
col – column to select
- sort_column(order)[source]¶
Sort the current column.
- Parameters:
order – order of sort (0 for ascending, 1 for descending)
- sort_updated(column, order)[source]¶
Update project and tab parameters after a sort.
- Parameters:
column – index of that was sorted
order – boolean of the new order
- update_table(take_tags_to_update=False)[source]¶
Fill the table with the project’s data.
Only called when switching project to completely reset the table.
- Parameters:
take_tags_to_update – boolean
- update_visualized_columns(old_tags, showed)[source]¶
Update the tags shown in the table.
- Parameters:
old_tags – old list of visualized tags
showed – list of tags to display
- class populse_mia.user_interface.data_browser.data_browser.TimeFormatDelegate(parent=None)[source]¶
Bases:
QItemDelegate
Delegate that is used to handle times in the TableDataBrowser.
- createEditor(parent, option, index)[source]¶
Override of the createEditor method, called to generate the widget.
- Parameters:
parent – QWidget parent
option – Only used to overload the QItemDelegate class
index – Only used to overload the QItemDelegate class
- Returns:
The QWidget with a specified format
populse_mia.user_interface.data_browser.mini_viewer module¶
This module provides the MiniViewer class, which is a PyQt-based widget designed for rapid visualization of medical scans. The MiniViewer allows users to view and interact with 3D, 4D, and 5D NIfTI images, providing tools to navigate through slices and time points.
Key Features: - Visualize single images per scan with cursors to move in multiple dimensions. - Display all images of the greater dimension of the scan. - Support for 3D, 4D, and 5D NIfTI images. - Configurable display settings, including orientation and slice navigation. - Integration with project-specific configurations and preferences.
- Contains:
- Class:
MiniViewer
- class populse_mia.user_interface.data_browser.mini_viewer.MiniViewer(project)[source]¶
Bases:
QWidget
MiniViewer allows rapid visualization of scans with either a single image per scan or all images of the greater dimension of the scan.
Displayed images depend on their dimension: - 3D: Display all slices. - 4D: Display the middle slice of the third dimension for each time of the
fourth dimension.
- 5D: Display the middle slice of the third dimension for the first time
of the fourth dimension for each time of the fifth dimension.
- Note:
idx corresponds to the index of the displayed image
idx in [0, self.max_scans]
- most of the class’s attributes are lists of 0 to self.max_scans
elements
- __init__(project)[source]¶
Initialize the MiniViewer object.
- Parameters:
project – Current project in the software.
- boxSlider(idx)[source]¶
Define horizontal sliders connections and thumbnail labels.
- Parameters:
(int) (idx) – The selected index.
- changePosValue(idx, cursor_to_change)[source]¶
Change the value of a cursor for the selected index.
- Parameters:
idx – the selected index
cursor_to_change – the cursor to change (1, 2 or 3)
- check_box_cursors_state_changed()[source]¶
Update the config file when the state of the checkbox to chain the cursors changes.
- createDimensionLabels(idx)[source]¶
Create the dimension labels for the selected index.
- Parameters:
idx – the selected index
- createFieldValue()[source]¶
Create a field where will be displayed the position of a cursor.
- Returns:
the corresponding field
- create_slider(maxm=0, minm=0, pos=0)[source]¶
Generate an horizontal slider.
- Parameters:
maxm – slider’s maximum
minm – slider’s minimum
pos – slider’s initial value
- Returns:
the slider object
- displayPosValue(idx)[source]¶
Display the position of each cursor for the selected index.
- Parameters:
idx – the selected index
- image2DModifications(idx, im2D=None)[source]¶
Apply modifications to display the image correctly.
- Parameters:
idx – the selected index
im2D – image to modify
- image_to_pixmap(im, i)[source]¶
Create a 2D pixmap from a N-D Nifti image.
- Parameters:
im – Nifti image
i – index of the slide
- Returns:
the corresponding pixmap
- indexImage(idx)[source]¶
Update all slider values according to the size of the current image.
- Parameters:
idx – the selected index
Display the 2D image for the selected index.
- Parameters:
idx – the selected index
- setThumbnail(file_path_base_name, idx)[source]¶
Set the thumbnail tag value under the image frame.
- Parameters:
file_path_base_name – basename of the selected path
idx – index of the image
- show_slices(file_paths)[source]¶
Creates the thumbnails from the selected file paths.
- Parameters:
file_paths – the selected file paths
- update_nb_slices()[source]¶
Update the config file and the thumbnails.
Called when the number of slices to visualize changes.
populse_mia.user_interface.data_browser.modify_table module¶
Database cell editor module for list-type values.
This module provides dialog interfaces for editing complex data types in the Mia data browser. It specifically handles the editing of list-type values such as arrays of numbers, strings, or dates.
The ModifyTable dialog creates an interactive table representation of lists, allowing users to add, edit, or remove items while ensuring type safety and database consistency.
- Contains:
- Class:
ModifyTable
- class populse_mia.user_interface.data_browser.modify_table.ModifyTable(project, value, types, scans, tags)[source]¶
Bases:
QDialog
Dialog to modify cell contents containing lists in the data browser tab.
This dialog provides a user interface to edit cells that contain list values. It displays the list elements in a table and allows users to add or remove elements.
- __init__(project, value, types, scans, tags)[source]¶
Initialize the ModifyTable dialog.
- Parameters:
project – Instance of the current project
value – List of values in the cell to be modified
types – Allowed value types for validation
scans – Scan identifiers corresponding to rows
tags – Tag identifiers corresponding to columns
- fill_table()[source]¶
Populate the table with the current list elements.
Configures the table dimensions, populates cells with values, and adjusts table size to fit content within reasonable bounds.
populse_mia.user_interface.data_browser.rapid_search module¶
Rapid Search Widget Module
This module provides the RapidSearch widget, a specialized QLineEdit component for performing quick searches across visualized tags in the data browser table.
The RapidSearch widget enables users to filter DataBrowser using various search patterns and wildcards. It supports searching for specific text patterns as well as finding entries with undefined or missing values.
- Contains:
- Class:
RapidSearch
- class populse_mia.user_interface.data_browser.rapid_search.RapidSearch(databrowser)[source]¶
Bases:
QLineEdit
Widget for pattern searching in table data across visualized tags.
Supports special search syntax: - ‘%’: Wildcard for any string - ‘_’: Wildcard for any single character - ‘Not Defined’: Matches scans with missing values
Dates should be formatted as: yyyy-mm-dd hh:mm:ss.fff
- __init__(databrowser)[source]¶
Initialize the RapidSearch widget.
- Parameters:
databrowser – Parent data browser widget
- static prepare_filter(search, tags, scans)[source]¶
Create a filter for searching text across specified tags.
- Parameters:
(str) (search) – Search pattern to look for
(list) (scans) – List of tags to search within
(list) – List of scans to restrict the search to
- Return (str):
SQL-like filter expression for the search