Skip to content

Commit

Permalink
Merge branch 'cudmore-dev' into johnson-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jtle00 committed Jul 9, 2024
2 parents d6d69d2 + 7d765b0 commit 6faa772
Show file tree
Hide file tree
Showing 38 changed files with 935 additions and 887 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ permissions:

jobs:
test:
runs-on: ubuntu-latest
# runs-on: ubuntu-latest
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
# platform: [ubuntu-latest, windows-latest, macos-latest]
platform: [windows-latest, macos-latest]
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3
Expand All @@ -25,8 +27,11 @@ jobs:
cache-dependency-path: setup.py
- name: Install dependencies
run: |
# pip install .
pip install '.[tests]'
# so we don't need to depend on pip install MapManagerCore
git clone -b cudmore-dev https://github.com/mapmanager/MapManagerCore.git
pip install MapManagerCore/.
- name: Run flake8
run: |
flake8 ./pymapmanager --count --select=E9,F63,F7,F82 --show-source --statistics
Expand All @@ -35,7 +40,10 @@ jobs:
run: |
# exlude anything that requires large data (it is not included in PyPi)
# pytest --cov=./tests --cov-report=xml --ignore=tests/test_gen_example_notebook.py
pytest --cov=./tests --cov-report=xml
# need to specify tests/ folder because now we have a
# MapManagerCore folder which has its own tests/
pytest -s --cov=./tests --cov-report=xml tests/
# pytest tests/interface/test_app_tmp.py
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion pymapmanager/analysisParams.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def _getDocs(self) -> str:
# Save button will send the signals to backend for whatever changed

if __name__ == '__main__':
dp = AnalysisParams()
dp = _old_AnalysisParams()
print(dp._getDocs())

# dp.buildAnalysisParamUI()
73 changes: 28 additions & 45 deletions pymapmanager/annotations/baseAnnotationsCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
from mapmanagercore import MapAnnotations
from mapmanagercore.layers.line import clipLines

from pymapmanager.interface2.stackWidgets.event.spineEvent import EditSpinePropertyEvent

from pymapmanager._logger import logger

class AnnotationsCore:
def __init__(self,
mapAnnotations : "???", # TODO: update on merge 20240513
# analysisParams : "AnalysisParams",
mapAnnotations : MapAnnotations,
sessionID = 0,
):
"""
Expand All @@ -26,7 +27,7 @@ def __init__(self,
self._sessionID = sessionID

# full map, multiple session ids (timepoint, t)
self._fullMap : "AnnotationsLayers" = mapAnnotations
self._fullMap : MapAnnotations = mapAnnotations
# mapmanagercore.annotations.single_time_point.layers.AnnotationsLayers

#filtered down to just sessionID
Expand Down Expand Up @@ -112,7 +113,7 @@ def getValue(self, colName : str, rowIdx : int):
def getValues(self,
colName : List[str],
rowIdx : Union[int, List[int], None] = None,
) -> Union[np.ndarray, None]:
) -> Optional[np.ndarray]:
"""Get value(s) from a column or list of columns.
Parameters
Expand All @@ -130,17 +131,17 @@ def getValues(self,
# logger.info(f'{rowIdx} {type(rowIdx)}')

df = self.getDataFrame() # geopandas.geodataframe.GeoDataFrame

# TODO: 042024 implement a list of columns
# if not isinstance(colName, list):
# colName = [colName]

#if not self.columns.columnIsValid(colName):
# print('df:')
# print(df.index)

if colName not in list(df.columns):
logger.error(f'did not find column name "{colName}"')
return

if rowIdx is None:
# TODO: this won't work, need to get actual row labels
# some may be missing after delet
rowIdx = range(self.numAnnotations) # get all rows
elif not isinstance(rowIdx, list):
rowIdx = [rowIdx]
Expand All @@ -150,7 +151,7 @@ def getValues(self,
return ret

except (KeyError):
logger.error(f'bad rowIdx(s) {rowIdx}, colName:{colName} range is 0...{len(self)-1}')
logger.error(f'bad rowIdx(s) {rowIdx}, colName:{colName} values are in row labels')
return None

def moveSpine(self, spineID :int, x, y, z):
Expand Down Expand Up @@ -347,7 +348,7 @@ def deleteAnnotation(self, rowIdx : Union[int, List[int]]) -> None:

self._buildDataFrame()

def editSpine(self, editSpineProperty : "EditSpineProperty"):
def editSpine(self, editSpineProperty : EditSpinePropertyEvent):
# spineID:117 col:isBad value:True
# logger.info(editSpineProperty)
logger.info(f"stack widget editSpineProperty {editSpineProperty}")
Expand All @@ -362,6 +363,16 @@ def editSpine(self, editSpineProperty : "EditSpineProperty"):

class LineAnnotationsCore(AnnotationsCore):

@property
def numSegments(self):
return len(self._fullMap.segments[:])

def newSegment(self):
return self._fullMap.newSegment()

def appendSegmentPoint(self, segmentID : int, x : int, y: int, z : int):
self._fullMap.appendSegmentPoint(segmentID, x, y, z)

def getSummaryDf(self):
"""DataFrame with per segment info (one segment per ro)
"""
Expand All @@ -373,6 +384,11 @@ def _buildSummaryDf(self) -> pd.DataFrame:
self._summaryDf = pd.DataFrame()
self._summaryDf['segmentID'] = self._df['segmentID'].unique()

lengthList = []
for row in range(len(self._summaryDf)):
lengthList.append(self._fullMap.segments['segment'].loc[row].length)
self._summaryDf['length'] = lengthList

def _buildDataFrame(self):

_startSec = time.time()
Expand Down Expand Up @@ -414,7 +430,7 @@ def _buildDataFrame(self):

#
# left/right
logger.warning('left/right is slow, can we get this pre-built and saved into zarr')
# logger.warning('left/right is slow, can we get this pre-built and saved into zarr')

# TODO: 6/19 fix xyLeft and xyRight
# TODO: put ths back in, the backend changed. We no longer have "segmentLeft" or "segmentRight"
Expand Down Expand Up @@ -499,36 +515,3 @@ def getMedianZ(self, segmentID : int):
yMedian = np.median(df['y'])
zMedian = np.median(df['z'])
return (int(xMedian), int(yMedian), int(zMedian) )

if __name__ == '__main__':
from pymapmanager._logger import setLogLevel
setLogLevel()

# _testEditSpineProperty()

sys.exit(1)

zarrPath = '../MapManagerCore/data/rr30a_s0us.mmap'
map = MapAnnotations(MMapLoader(zarrPath).cached())

sac = SpineAnnotationsCore(map)

print(sac.getDataFrame().columns)

segmentID = None
roiTypes = None
zSlice = 20
zPlusMinus = 5

value = sac.getValue('x', 2)
print(f'x:{value}')
value = sac.getValues('y', [2, 3, 4])
print(f'y:{value}')
print(type(value))

row = sac.getRow(2)
print('row')
print(row)

# spineDf = sac.getSegmentPlot(segmentID, roiTypes, zSlice, zPlusMinus)
# print(spineDf)
59 changes: 0 additions & 59 deletions pymapmanager/annotations/baseAnnotationsMutate.py

This file was deleted.

3 changes: 1 addition & 2 deletions pymapmanager/interface2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from .pyMapManagerApp2 import PyMapManagerApp

from .mainMenus import PyMapManagerMenus

from .mainWindow import MainWindow

from .preferences import Preferences

from .appDisplayOptions import AppDisplayOptions
from .appDisplayOptions import AppDisplayOptions
4 changes: 3 additions & 1 deletion pymapmanager/interface2/appDisplayOptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pymapmanager._logger import logger

class AppDisplayOptions():
"""Class to encapsulate all display options.
Expand Down Expand Up @@ -43,6 +45,7 @@ def _getDefaultDisplayOptions(self):
theDict['windowState']['height'] = 500 # position on screen

# TODO: pass into imageplotwidget
theDict['windowState']['doSlidingZ'] = False # added 20240706
theDict['windowState']['zPlusMinus'] = 3

# interface.pointPlotWidget
Expand Down Expand Up @@ -91,5 +94,4 @@ def _getDefaultDisplayOptions(self):
# abj: 6/20
theDict['lineDisplay']['radius'] = 3


return theDict
4 changes: 3 additions & 1 deletion pymapmanager/interface2/core/scatter_plot_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,9 @@ def __init__(self,
"""

super().__init__(parent=parent)
self._blockSlots : bool = False

# abb not used
# self._blockSlots : bool = False

self.dict = {"X Stat" : "",
"Y Stat" : "",
Expand Down
Loading

0 comments on commit 6faa772

Please sign in to comment.