Skip to content

Commit 69b285c

Browse files
committed
merge j-dev 20241206
1 parent 72e90c6 commit 69b285c

9 files changed

Lines changed: 98 additions & 459 deletions

File tree

pymapmanager/annotations/baseAnnotationsCore.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
from pymapmanager._logger import logger
2424

25+
def getUserTypeMarkers_mpl():
26+
return ['o', 'v', '^', '<', '>', 'D', 'd', '*', 'p' ,'h']
27+
2528
class AnnotationsCore:
2629
def __init__(self,
2730
timeSeriesCore : TimeSeriesCore, # multi timepoint
@@ -262,7 +265,7 @@ def getDirty(self):
262265
return self._isDirty
263266

264267
class SpineAnnotationsCore(AnnotationsCore):
265-
268+
266269
def _buildDataFrame(self):
267270
"""Dataframe representing backend spines, one row per spine.
268271
@@ -289,7 +292,26 @@ def _buildDataFrame(self):
289292
print(allSpinesDf)
290293

291294
allSpinesDf['roiType'] = 'spineROI'
292-
allSpinesDf.insert(0,'index', allSpinesDf.index) # index is first column
295+
allSpinesDf.insert(0,'index', allSpinesDf.index) # index is first column (use this as row label)
296+
297+
# if len(allSpinesDf) > 0:
298+
# TODO make this work
299+
# marker color
300+
# allSpinesDf['markerColor'] = 'm'
301+
# try:
302+
# _notAcceptRowLabels = allSpinesDf[ not allSpinesDf['accept'] ]
303+
# allSpinesDf.loc[_notAcceptRowLabels, 'markerColor'] = 'w'
304+
# except (KeyError) as e:
305+
# logger.error(f'{e}')
306+
# logger.error(f'available columns are: {allSpinesDf.columns}')
307+
308+
# TODO make this work
309+
# _userTypeMarkers = getUserTypeMarkers_mpl()
310+
# allSpinesDf['mplMarker'] = 'o'
311+
# for userType in range(10):
312+
# # 10 user types
313+
# _userTypeRowLabels = allSpinesDf[ allSpinesDf['userType'] == userType]
314+
# allSpinesDf.loc[_userTypeRowLabels, 'mplMarker'] = _userTypeMarkers[userType]
293315

294316
self._df = allSpinesDf
295317

@@ -740,6 +762,8 @@ def getPivotPoint(self):
740762

741763
# find pivotDistance within point distance, that is what we plot
742764
pivotDistances = self._summaryDf["Pivot Distance"]
765+
"""List[float], one item per segment id"""
766+
743767
pointDistance = self._summaryDf["Point Distances"]
744768

745769
returnPointX = []

pymapmanager/interface2/core/scatter_plot_widget.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def on_scatter_toolbar_table_click(self):
503503
statName = self.myTableWidget.item(row,0).text()
504504
self.signalUpdateStat.emit(self._id, statName)
505505

506-
class ScatterPlotWidget(QtWidgets.QWidget):
506+
class ScatterPlotWidget_(QtWidgets.QWidget):
507507
"""Plot x/y statistics as a scatter.
508508
509509
Get stat names and variables from sanpy.bAnalysisUtil.getStatList()
@@ -721,8 +721,7 @@ def getfilteredDFWithIndexList(self, filterStr, filterColumn) -> pd.DataFrame:
721721
return df, indexList
722722

723723
def getFilteredIndexList(self, filterDF):
724-
"""
725-
Calculate the new list of indexes after hue filtering DF
724+
"""Calculate the new list of indexes after hue filtering DF.
726725
"""
727726
hueColumn = self.dict["hueColumn"]
728727
currentHueID = float(self.dict["currentHueID"])
@@ -756,7 +755,7 @@ def setScatterPlot(self, xStat, yStat, xyStatIndex):
756755
myColorMap.append("white")
757756
else:
758757
if hueColumn != "None":
759-
logger.info(f"hueColumn {hueColumn} id:{id}")
758+
logger.info(f'hueColumn: "{hueColumn}" id:{id}')
760759
hueId = self._df[hueColumn].iloc[id]
761760
myColorMap.append(self.color[hueId])
762761

@@ -1222,39 +1221,28 @@ def _switchScatter(self):
12221221
self.myHighlighter.resetHighlighter(self.axScatter, np.array([]), np.array([]), np.array([]))
12231222

12241223
# IMPORTANT SIGNAL-SLOT CONNECTION (outside wrapper -> inside)
1225-
def selectHighlighterPoints(self, rowIndexes):
1224+
def selectHighlighterPoints(self, rowIndexes : List[int]):
12261225
""" Select Data in Highlighter Class
12271226
12281227
This function needs to be connected within wrapper class.
12291228
Outside selection emits signal to this function to update highlighter plot
12301229
Args:
12311230
rowIndexes: indexes of rows that need to be selected within highlighter plot
12321231
"""
1233-
1234-
# If nothing is selected empty highlighter plot
1235-
if rowIndexes == None:
1232+
if rowIndexes is None or rowIndexes == []:
12361233
self.myHighlighter._setData([], [])
12371234
else:
1238-
# Otherwise get the appropriate values and plot
12391235
columnNameX = self.xPlotWidget.getCurrentStat()
12401236
columnNameY = self.yPlotWidget.getCurrentStat()
1241-
1242-
# Get column values into respective lists
1243-
xFilteredVals = self._df[columnNameX].tolist()
1244-
yFilteredVals = self._df[columnNameY].tolist()
1245-
# logger.info(f"rowIndexes {rowIndexes}")
1246-
# logger.info(f"xFilteredVals {xFilteredVals}")
1247-
# logger.info(f"yFilteredVals {yFilteredVals}")
12481237

1249-
# Acquire only selected rowIndexes from the lists
1250-
xDFStat = [xFilteredVals[i] for i in rowIndexes]
1251-
yDFStat = [yFilteredVals[i] for i in rowIndexes]
1252-
self.myHighlighter._setData(xDFStat, yDFStat)
1238+
# pull x/y values from selected row(s)
1239+
xSelectValues = self._df.loc[rowIndexes, columnNameX].tolist()
1240+
ySelectValues = self._df.loc[rowIndexes, columnNameY].tolist()
1241+
1242+
self.myHighlighter._setData(xSelectValues, ySelectValues)
12531243

12541244
# Store selected rows for later use
12551245
self.storedRowIdx = rowIndexes
1256-
logger.info(f"self.storedRowIdx {self.storedRowIdx}")
1257-
logger.info("select Highlighter Points called")
12581246

12591247
def getHighlightedIndexes(self):
12601248
return self.storedRowIdx

pymapmanager/interface2/mapWidgets/mapWidget.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,9 @@ def openStackRun(self,
188188
# toggle interface
189189
# dict_keys(['top toolbar', 'Point List', 'Line List', 'image plot', 'Histogram'])
190190
if _multipleTp:
191-
bsw._toggleWidget("top toolbar", False)
191+
bsw._toggleWidget("Top Toolbar", False)
192192
bsw._toggleWidget("Point List", False)
193-
bsw._toggleWidget("Line List", False)
194-
# bsw._toggleWidget("tracing widget qqq", False)
195-
bsw._toggleWidget("Histogram", False)
193+
bsw._toggleWidget("Segment List", False)
196194
# bsw._toggleWidget("Status Bar", False)
197195

198196
# select a point and zoom

pymapmanager/interface2/runInterfaceBob.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,31 @@
1111
def run():
1212
app = PyMapManagerApp(sys.argv)
1313

14-
#
1514
# open a single timepoint map with segments and spines
16-
# path = mapmanagercore.data.getSingleTimepointMap()
15+
path = mapmanagercore.data.getSingleTimepointMap()
16+
17+
# path = '/Users/cudmore/Sites/data/rr30a_s0u_20241205.mmap'
18+
19+
# path = '/Users/cudmore/Dropbox/data/ome-zarr/single_timepoint_v2.ome.zarr'
20+
21+
# .mmap (zarr folder, local)
22+
# path = '/Users/cudmore/Sites/MapManagerCore-Data/data/multi_timepoint_map.mmap'
23+
24+
# .mmap (zip file, local)
25+
# path = '/Users/cudmore/Sites/MapManagerCore-Data/data/multi_timepoint_map_zip.mmap'
26+
27+
# .ome.zar (local)
28+
# path = '/Users/cudmore/Sites/MapManagerCore-Data/data/single_timepoint.ome.zarr'
29+
30+
# .ome.zar (remote)
31+
# path = 'https://github.com/mapmanager/MapManagerCore-Data/raw/main/data/single_timepoint.ome.zarr'
32+
33+
# random ome zarr file (remote)
34+
# path = 'https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr'
35+
# random ome zarr file (local)
36+
# path = '/Users/cudmore/Dropbox/data/ome-zarr/6001240.ome.zarr'
1737

1838
# a single timepoint tif file
19-
# error in images
20-
# IndexError: index -2 is out of bounds for axis 0 with size 1
2139
# path = mapmanagercore.data.getTiffChannel_1()
2240

2341
# map with segments and spines (no segments connected)
@@ -35,7 +53,7 @@ def run():
3553

3654
# a mmap with multiple timepoints, connects segments and spines
3755
# path = '/Users/cudmore/Desktop/multi_timepoint_map_seg_spine_connected.mmap'
38-
# path = mapmanagercore.data.getMultiTimepointMap()
56+
path = mapmanagercore.data.getMultiTimepointMap()
3957

4058
# mw will be map widget if path has multiple timepoints, otherwise mw is a stackwidget2
4159
mw = app.loadStackWidget(path)

pymapmanager/interface2/stackWidgets/imagePlotWidget2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,11 @@ def _setSlice(self, sliceNumber : int, doEmit = True):
648648

649649
# print('2) ch1_image:', ch1_image.shape, ch1_image.dtype)
650650

651+
_xShape = ch0_image.shape[0]
652+
_yShape = ch0_image.shape[1]
653+
sliceImage = np.ndarray((_xShape,_yShape,3))
654+
651655
# magenta is blue + red
652-
sliceImage = np.ndarray((1024,1024,3))
653656
sliceImage[:,:,0] = ch1_image # red
654657
sliceImage[:,:,1] = ch0_image # green
655658
sliceImage[:,:,2] = ch1_image # blue

0 commit comments

Comments
 (0)