straditize.widgets.samples_table module¶
A table for manipulating samples
This module defines the sample editors, either for editing the samples in the
straditizer image (SingleCrossMarksEditor
) or in a separate
Figure
(MultiCrossMarksEditor
)
Disclaimer
Copyright (C) 2018-2019 Philipp S. Sommer
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Classes
|
An editor for cross marks in multiple axes |
|
A table model to handle multiple connected cross marks in different axes |
|
A table view set up by cross marks from multiple axes |
|
The editor for cross marks on a single axes |
|
A table model to handle cross marks within one single axis |
|
A table for visualizing marks from a single axes |
-
class
straditize.widgets.samples_table.
MultiCrossMarksEditor
(straditizer, axes=None, *args, **kwargs)[source]¶ Bases:
psyplot_gui.common.DockMixin
,PyQt5.QtWidgets.QWidget
An editor for cross marks in multiple axes
- Parameters
straditizer (weakref.ref) – The reference to the straditizer
axes (matplotlib.axes.Axes) – The matplotlib axes corresponding to the marks
Attributes
Plot the reconstructed data
A
weakref
to theMethods
create_view
([axes])Create the
MultiCrossMarksView
of the editorSave the samples to the
straditizer
without removing themto_dock
(main[, title, position, docktype])Enable the fitting so selected digitized data
toggle_fmt_button
(text)Update the format of the table
Miscallaneous
The QDockWidget for the
DataFrameEditor
-
cb_plot_lines
= None¶ Plot the reconstructed data
-
create_view
(axes=None)[source]¶ Create the
MultiCrossMarksView
of the editor- Parameters
axes (list of
matplotlib.axes.Axes
) – The matplotlib axes for the marks
-
dock_cls
¶
-
save_samples
()[source]¶ Save the samples to the
straditizer
without removing them
-
straditizer
= None¶ A
weakref
to thestraditizer
-
class
straditize.widgets.samples_table.
MultiCrossMarksModel
(marks, columns, straditizer, axes=None, occurences_value=-9999)[source]¶ Bases:
PyQt5.QtCore.QAbstractTableModel
A table model to handle multiple connected cross marks in different axes
- Parameters
marks (list of
straditize.cross_mark.CrossMarks
) – the initial markscolumns (list of str) – the column names to use
straditizer (straditize.straditizer.Straditizer) – The straditizer that manages the marks
axes (list of
matplotlib.axes.Axes
) – The matplotlib axes that contain the marksoccurences_value (float) – The value that marks an occurence
Methods
columnCount
([index])The number of rows in the table
data
(self, QModelIndex, role)delRow
(irow)flags
(index)Set flags
get_cell_mark
(row, column)Get the mark for a given cell in the table
Return current format
headerData
(section, orientation[, role])Set header data
insertRow
(irow[, xa, ya])Insert a row into the table
load_new_marks
(mark)Add a new mark into the table after they have been added by the user
Connect the samples through visual
lines
Remove the
lines
remove_mark
(mark)Remove a mark from the table after it has been removed by the user
reset
()Reset the model
rowCount
([index])The number of rows in the table
setData
(index, value[, role, change_type])Cell content change
set_format
(fmt)Change display format
set_marks
(marks, columns)Set the
marks
attribute from the given columnsSort the marks based on there y-position
update_after_move
(old_pos, mark)Update the
lines
or plot themAttributes
Get the samples_locs
The figure of the cross marks
Iter over all marks in the
marks
attributeA list of
matplotlib.lines.Line2D
that connects the cross marksA list
[float, list]
where the firstfloat
is the vertical-
property
df
¶ Get the samples_locs
-
property
fig
¶ The figure of the cross marks
-
get_cell_mark
(row, column)[source]¶ Get the mark for a given cell in the table
- Parameters
- Returns
The corresponding mark from the
marks
attribute- Return type
-
lines
= []¶ A list of
matplotlib.lines.Line2D
that connects the cross marks and plots a reconstruction based on them
-
load_new_marks
(mark)[source]¶ Add a new mark into the table after they have been added by the user
- Parameters
mark (straditize.cross_mark.CrossMarks) – The added mark
-
marks
= []¶ A list
[float, list]
where the firstfloat
is the vertical position and the secondlist
is a list of the correspondingCrossMarks
instances
-
remove_mark
(mark)[source]¶ Remove a mark from the table after it has been removed by the user
- Parameters
mark (straditize.cross_mark.CrossMarks) – The removed mark
-
set_marks
(marks, columns)[source]¶ Set the
marks
attribute from the given columns- Parameters
marks (list of
straditize.cross_mark.CrossMarks
) – the initial markscolumns (list of str) – the column names to use
-
class
straditize.widgets.samples_table.
MultiCrossMarksView
(marks, full_df, *args, **kwargs)[source]¶ Bases:
PyQt5.QtWidgets.QTableView
A table view set up by cross marks from multiple axes
The model for this table is the
MultiCrossMarksModel
- Parameters
marks (list of
straditize.cross_mark.CrossMarks
) – the initial marksfull_df (pandas.DataFrame) – The data fame of the full digitized data
Methods
contextMenuEvent
(event)Reimplement Qt method
fit2data
()Fit the selected cells to the
full_df
init_model
(marks, *args, **kwargs)Initialize the table
MultiCrossMarksModel
Insert a row above the selection
Insert a row below the selection
moveCursor
(cursor_action, modifiers)Update the table position.
resizeEvent
(event)Update the frozen column dimensions.
scrollTo
(index, hint)Scroll the table.
Setup context menu
Show all marks
Show only the marks selected in the table
update_section_height
(logical_index, …)Update the vertical width of the frozen column when a
update_section_width
(logical_index, …)Update the horizontal width of the frozen column when a
zoom_to_cells
(rows, cols)Zoom to specific cells in the plot
Zoom to the selected cells in the plot
Attributes
The
pandas.DataFrame
representing the full digitized data-
full_df
= None¶ The
pandas.DataFrame
representing the full digitized data from thestraditize.binary.DataReader.full_df
data frame
-
init_model
(marks, *args, **kwargs)[source]¶ Initialize the table
MultiCrossMarksModel
-
moveCursor
(cursor_action, modifiers)[source]¶ Update the table position.
Updates the position along with the frozen column when the cursor (selector) changes its position
-
resizeEvent
(event)[source]¶ Update the frozen column dimensions.
Updates takes place when the enclosing window of this table reports a dimension change
-
scrollTo
(index, hint)[source]¶ Scroll the table.
It is necessary to ensure that the item at index is visible. The view will try to position the item according to the given hint. This method does not takes effect only if the frozen column is scrolled.
Setup context menu
-
update_section_height
(logical_index, old_size, new_size)[source]¶ Update the vertical width of the frozen column when a change takes place on any of the rows
-
update_section_width
(logical_index, old_size, new_size)[source]¶ Update the horizontal width of the frozen column when a change takes place in the first column of the table
-
class
straditize.widgets.samples_table.
SingleCrossMarksEditor
(straditizer, axes=None, *args, **kwargs)[source]¶ Bases:
straditize.widgets.samples_table.MultiCrossMarksEditor
The editor for cross marks on a single axes
- Parameters
straditizer (weakref.ref) – The reference to the straditizer
axes (matplotlib.axes.Axes) – The matplotlib axes corresponding to the marks
Methods
create_view
([axes])Create the
SingleCrossMarksView
of the editorSave the samples to the
straditizer
without removing them-
create_view
(axes=None)[source]¶ Create the
SingleCrossMarksView
of the editor- Parameters
axes (list of
matplotlib.axes.Axes
) – The matplotlib axes for the marks
-
class
straditize.widgets.samples_table.
SingleCrossMarksModel
(*args, **kwargs)[source]¶ Bases:
straditize.widgets.samples_table.MultiCrossMarksModel
A table model to handle cross marks within one single axis
- Parameters
column_bounds (np.ndarray of shape
(N, 2)
) – The column boundariesy0 (float) – The upper extent of the data image
Methods
columnCount
([index])The number of rows in the table
delRow
(irow)get_cell_mark
(row, column)Get the mark for a given cell in the table
insertRow
(irow[, xa, ya])Insert a row into the table
load_new_marks
(mark)Add a new mark into the table after they have been added by the user
Connect the samples through visual
lines
remove_mark
(mark)Remove a mark from the table after it has been removed by the user
set_marks
(marks, columns)Set the
marks
attribute from the given columnsupdate_after_move
(old_pos, mark)Update the
lines
or plot themAttributes
Get the samples_locs
Iter over all marks in the
marks
attributeA list of tuples like
(float, mark)
wherefloat
is the y-pixel-
property
df
¶ Get the samples_locs
-
get_cell_mark
(row, column)[source]¶ Get the mark for a given cell in the table
- Parameters
- Returns
The corresponding mark from the
marks
attribute- Return type
-
load_new_marks
(mark)[source]¶ Add a new mark into the table after they have been added by the user
- Parameters
mark (straditize.cross_mark.CrossMarks) – The added mark
-
marks
= []¶ A list of tuples like
(float, mark)
wherefloat
is the y-pixel andmark
is the correspondingstraditize.cross_mark.CrossMarks
instance
-
remove_mark
(mark)[source]¶ Remove a mark from the table after it has been removed by the user
- Parameters
mark (straditize.cross_mark.CrossMarks) – The removed mark
-
set_marks
(marks, columns)[source]¶ Set the
marks
attribute from the given columns- Parameters
marks (list of
straditize.cross_mark.CrossMarks
) – the initial markscolumns (list of str) – the column names to use
-
class
straditize.widgets.samples_table.
SingleCrossMarksView
(marks, full_df, *args, **kwargs)[source]¶ Bases:
straditize.widgets.samples_table.MultiCrossMarksView
A table for visualizing marks from a single axes
- Parameters
marks (list of
straditize.cross_mark.CrossMarks
) – the initial marksfull_df (pandas.DataFrame) – The data fame of the full digitized data
Methods
fit2data
()Fit the selected cells to the
full_df
init_model
(marks, *args, **kwargs)Initialize the table
SingleCrossMarksModel
zoom_to_cells
(rows, cols)Zoom to specific cells in the plot
-
init_model
(marks, *args, **kwargs)[source]¶ Initialize the table
SingleCrossMarksModel
- Parameters
%(SingleCrossMarksModel.parameters)s –