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.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.

add_tag()[source]

Add a new tag to visualize in the count table.

count_scans()[source]

Count the number of scans based on selected tags and display the result.

fill_first_tags()[source]

Fill the table cells for the first (n-1) selected tags.”

fill_headers()[source]

Fills the headers of the table depending on the selected tags

fill_last_tag()[source]

Fills the cells corresponding to the last selected tag

fill_values(idx)[source]

Fill values_list depending on the visualized tags

Parameters:

idx – index of the select tag

static prepare_filter(couples)[source]

Prepares the filter in order to fill the count table.

Parameters:

couples – (tag, value) couples

Returns:

Str query of the corresponding filter

refresh_layout()[source]

Updates the layout of the widget

remove_tag()[source]

Removes a tag to visualize in the count table

select_tag(idx)[source]

Opens a pop-up to select which tag to visualize in the count table

Parameters:

idx – the index of the selected push button

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

add_tag_pop_up()[source]

Display the add tag pop-up.

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

clone_tag_pop_up()[source]

Display the clone tag pop-up.

connect_actions()[source]

Connect methods to actions.

connect_mini_viewer()[source]

Display the selected documents in the viewer.

connect_toolbar()[source]

Connect methods to toolbar.

count_table_pop_up()[source]

Open the count table pop-up.

create_layout()[source]

Create the layouts of the tab.

create_toolbar_view()[source]

Create the toolbar menu at the top of the tab

move_splitter()[source]

Check if the viewer’s splitter is at its lowest position.

open_filter()[source]

Open a project filter that has already been saved.

open_filter_infos()[source]

Apply the current filter.

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

remove_tag_pop_up()[source]

Display the pop-up to remove user tags.

Reset the rapid search bar.

Launch the advanced search.

search_str(str_search)[source]

Search a string in the table and updates the visualized documents.

Parameters:

str_search – string to search

send_documents_to_pipeline()[source]

Send the current list of scans to the Pipeline Manager.

update_database(database)[source]

Update the database in the software. Called when switching project (new, open, and save as).

Parameters:

database – New instance of Database

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.

__init__(parent=None)[source]
createEditor(parent, option, index)[source]

Override of the createEditor method, called to generate the widget.

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.

__init__(parent=None)[source]
createEditor(parent, option, index)[source]

Override of the createEditor method, called to generate the widget.

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.

__init__(parent=None)[source]
createEditor(parent, option, index)[source]

Override of the createEditor method, called to generate the widget.

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_columns()[source]

Add columns.

add_path()[source]

Call a pop-up to add any document to the project.

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

clear_cell()[source]

Clear the selected cells.

context_menu_table(position)[source]

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

display_file()[source]

Tries to display a file in the user’s preferred application.

display_unreset_values()[source]

Display an error message when trying to reset user tags.

edit_table_data_values()[source]

Change values in DataBrowser

fill_cells_update_table()[source]

Initialize and fill the cells of the table.

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

mouseReleaseEvent(event)[source]

Update table after mouse release.

Parameters:

event – event

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”

multiple_sort_pop_up()[source]

Display the multiple sort pop-up.

remove_scan()[source]

Remove documents from table and project.

reset_cell()[source]

Reset the selected cells to their original values.

reset_column()[source]

Reset the selected columns to their original values.

reset_row()[source]

Reset the selected rows to their original values.

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

select_all_columns()[source]

Select one or several column(s). Called from the context menu.

selection_changed()[source]

Update the tab view when the selection changes.

show_brick_history(scan)[source]

Show brick history pop-up.

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_colors()[source]

Update the background of all the cells.

update_selection()[source]

Update the selection after a search.

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

update_visualized_rows(old_scans)[source]

Update the list of documents (scans) in the table.

Parameters:

old_scans – old list of scans

visualized_tags_pop_up()[source]

Display the visualized tags pop-up.

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.

__init__(parent=None)[source]

Initialization of the class

Parameters:

parent – QWidget parent

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.

clear()[source]

Remove the Nibabel images to be able to remove it in the unit tests.

clear_layouts()[source]

Clear the final layout.

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

enableSliders(idx)[source]

Enable all the horizontal slider.

Parameters:

idx – the slider’s 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

mem_release()[source]

Reset all object lists to zero in order to preserve memory

navigImage(idx)[source]

Display the 2D image for the selected index.

Parameters:

idx – the selected index

openTagsPopUp()[source]

Open a pop-up to select the legend of the thumbnails.

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.

update_visualization_method()[source]

Update the config file and the thumbnails.

Called when the state of the checkbox to show all slices changes.

verify_slices(file_paths)[source]

Make ‘Show all slices’ checkbox unclickable if len(file_paths) > 1.

Parameters:

file_paths – the selected documents

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

add_item()[source]

Add a new element to the list with default value 0.

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.

rem_last_item()[source]

Remove the last element of the list if there’s more than one element.

Lists must maintain at least one element.

update_table_values(test=False)[source]

Validate user input and update the database with new values.

Validates each value against specified types and updates the database only if all values are valid.

Parameters:

(bool) (test) – Flag for testing mode, defaults to False