Skip to content

Commit

Permalink
merge j-dev 20241206
Browse files Browse the repository at this point in the history
  • Loading branch information
cudmore committed Dec 7, 2024
1 parent 72e90c6 commit 69b285c
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 459 deletions.
28 changes: 26 additions & 2 deletions pymapmanager/annotations/baseAnnotationsCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

from pymapmanager._logger import logger

def getUserTypeMarkers_mpl():
return ['o', 'v', '^', '<', '>', 'D', 'd', '*', 'p' ,'h']

class AnnotationsCore:
def __init__(self,
timeSeriesCore : TimeSeriesCore, # multi timepoint
Expand Down Expand Up @@ -262,7 +265,7 @@ def getDirty(self):
return self._isDirty

class SpineAnnotationsCore(AnnotationsCore):

def _buildDataFrame(self):
"""Dataframe representing backend spines, one row per spine.
Expand All @@ -289,7 +292,26 @@ def _buildDataFrame(self):
print(allSpinesDf)

allSpinesDf['roiType'] = 'spineROI'
allSpinesDf.insert(0,'index', allSpinesDf.index) # index is first column
allSpinesDf.insert(0,'index', allSpinesDf.index) # index is first column (use this as row label)

# if len(allSpinesDf) > 0:
# TODO make this work
# marker color
# allSpinesDf['markerColor'] = 'm'
# try:
# _notAcceptRowLabels = allSpinesDf[ not allSpinesDf['accept'] ]
# allSpinesDf.loc[_notAcceptRowLabels, 'markerColor'] = 'w'
# except (KeyError) as e:
# logger.error(f'{e}')
# logger.error(f'available columns are: {allSpinesDf.columns}')

# TODO make this work
# _userTypeMarkers = getUserTypeMarkers_mpl()
# allSpinesDf['mplMarker'] = 'o'
# for userType in range(10):
# # 10 user types
# _userTypeRowLabels = allSpinesDf[ allSpinesDf['userType'] == userType]
# allSpinesDf.loc[_userTypeRowLabels, 'mplMarker'] = _userTypeMarkers[userType]

self._df = allSpinesDf

Expand Down Expand Up @@ -740,6 +762,8 @@ def getPivotPoint(self):

# find pivotDistance within point distance, that is what we plot
pivotDistances = self._summaryDf["Pivot Distance"]
"""List[float], one item per segment id"""

pointDistance = self._summaryDf["Point Distances"]

returnPointX = []
Expand Down
32 changes: 10 additions & 22 deletions pymapmanager/interface2/core/scatter_plot_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def on_scatter_toolbar_table_click(self):
statName = self.myTableWidget.item(row,0).text()
self.signalUpdateStat.emit(self._id, statName)

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

def getFilteredIndexList(self, filterDF):
"""
Calculate the new list of indexes after hue filtering DF
"""Calculate the new list of indexes after hue filtering DF.
"""
hueColumn = self.dict["hueColumn"]
currentHueID = float(self.dict["currentHueID"])
Expand Down Expand Up @@ -756,7 +755,7 @@ def setScatterPlot(self, xStat, yStat, xyStatIndex):
myColorMap.append("white")
else:
if hueColumn != "None":
logger.info(f"hueColumn {hueColumn} id:{id}")
logger.info(f'hueColumn: "{hueColumn}" id:{id}')
hueId = self._df[hueColumn].iloc[id]
myColorMap.append(self.color[hueId])

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

# IMPORTANT SIGNAL-SLOT CONNECTION (outside wrapper -> inside)
def selectHighlighterPoints(self, rowIndexes):
def selectHighlighterPoints(self, rowIndexes : List[int]):
""" Select Data in Highlighter Class
This function needs to be connected within wrapper class.
Outside selection emits signal to this function to update highlighter plot
Args:
rowIndexes: indexes of rows that need to be selected within highlighter plot
"""

# If nothing is selected empty highlighter plot
if rowIndexes == None:
if rowIndexes is None or rowIndexes == []:
self.myHighlighter._setData([], [])
else:
# Otherwise get the appropriate values and plot
columnNameX = self.xPlotWidget.getCurrentStat()
columnNameY = self.yPlotWidget.getCurrentStat()

# Get column values into respective lists
xFilteredVals = self._df[columnNameX].tolist()
yFilteredVals = self._df[columnNameY].tolist()
# logger.info(f"rowIndexes {rowIndexes}")
# logger.info(f"xFilteredVals {xFilteredVals}")
# logger.info(f"yFilteredVals {yFilteredVals}")

# Acquire only selected rowIndexes from the lists
xDFStat = [xFilteredVals[i] for i in rowIndexes]
yDFStat = [yFilteredVals[i] for i in rowIndexes]
self.myHighlighter._setData(xDFStat, yDFStat)
# pull x/y values from selected row(s)
xSelectValues = self._df.loc[rowIndexes, columnNameX].tolist()
ySelectValues = self._df.loc[rowIndexes, columnNameY].tolist()

self.myHighlighter._setData(xSelectValues, ySelectValues)

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

def getHighlightedIndexes(self):
return self.storedRowIdx
Expand Down
6 changes: 2 additions & 4 deletions pymapmanager/interface2/mapWidgets/mapWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,9 @@ def openStackRun(self,
# toggle interface
# dict_keys(['top toolbar', 'Point List', 'Line List', 'image plot', 'Histogram'])
if _multipleTp:
bsw._toggleWidget("top toolbar", False)
bsw._toggleWidget("Top Toolbar", False)
bsw._toggleWidget("Point List", False)
bsw._toggleWidget("Line List", False)
# bsw._toggleWidget("tracing widget qqq", False)
bsw._toggleWidget("Histogram", False)
bsw._toggleWidget("Segment List", False)
# bsw._toggleWidget("Status Bar", False)

# select a point and zoom
Expand Down
28 changes: 23 additions & 5 deletions pymapmanager/interface2/runInterfaceBob.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,31 @@
def run():
app = PyMapManagerApp(sys.argv)

#
# open a single timepoint map with segments and spines
# path = mapmanagercore.data.getSingleTimepointMap()
path = mapmanagercore.data.getSingleTimepointMap()

# path = '/Users/cudmore/Sites/data/rr30a_s0u_20241205.mmap'

# path = '/Users/cudmore/Dropbox/data/ome-zarr/single_timepoint_v2.ome.zarr'

# .mmap (zarr folder, local)
# path = '/Users/cudmore/Sites/MapManagerCore-Data/data/multi_timepoint_map.mmap'

# .mmap (zip file, local)
# path = '/Users/cudmore/Sites/MapManagerCore-Data/data/multi_timepoint_map_zip.mmap'

# .ome.zar (local)
# path = '/Users/cudmore/Sites/MapManagerCore-Data/data/single_timepoint.ome.zarr'

# .ome.zar (remote)
# path = 'https://github.com/mapmanager/MapManagerCore-Data/raw/main/data/single_timepoint.ome.zarr'

# random ome zarr file (remote)
# path = 'https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr'
# random ome zarr file (local)
# path = '/Users/cudmore/Dropbox/data/ome-zarr/6001240.ome.zarr'

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

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

# a mmap with multiple timepoints, connects segments and spines
# path = '/Users/cudmore/Desktop/multi_timepoint_map_seg_spine_connected.mmap'
# path = mapmanagercore.data.getMultiTimepointMap()
path = mapmanagercore.data.getMultiTimepointMap()

# mw will be map widget if path has multiple timepoints, otherwise mw is a stackwidget2
mw = app.loadStackWidget(path)
Expand Down
5 changes: 4 additions & 1 deletion pymapmanager/interface2/stackWidgets/imagePlotWidget2.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,11 @@ def _setSlice(self, sliceNumber : int, doEmit = True):

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

_xShape = ch0_image.shape[0]
_yShape = ch0_image.shape[1]
sliceImage = np.ndarray((_xShape,_yShape,3))

# magenta is blue + red
sliceImage = np.ndarray((1024,1024,3))
sliceImage[:,:,0] = ch1_image # red
sliceImage[:,:,1] = ch0_image # green
sliceImage[:,:,2] = ch1_image # blue
Expand Down
Loading

0 comments on commit 69b285c

Please sign in to comment.