Skip to content

Commit

Permalink
block transferToServer if a crop is happening
Browse files Browse the repository at this point in the history
  • Loading branch information
raacampbell committed Jul 27, 2023
1 parent e3c2e0e commit b442a64
Show file tree
Hide file tree
Showing 24 changed files with 1,194 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.pyc

btpytools.egg-info/
build/
dist/
4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions btpytools.egg-info/.gitignore

This file was deleted.

10 changes: 10 additions & 0 deletions btpytools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DOWNSAMPLED_STACK_SUB_DIR = "*_micron" # Sub-directories in DOWNSAMPLED_DIR
DOWNSAMPLED_STACK_LOG_FILE = "ds_*.txt" # Wildcard for downsampled stacks
UNCROPPED_WILDCARD = "./Uncropped*_DELETE_ME_DELETE_ME"
CROPPED_TEMP_DIR_WILDCARD = "CROP_stitchedImages_*"
RECIPE_WILDCARD = "recipe*.yml"

# Related to registration directories.
Expand Down Expand Up @@ -105,6 +106,15 @@ def has_uncropped_stitched_images(t_path=""):
return file_glob_exist(t_path)


def is_currently_cropping(t_path=""):
"""Check if cropping is currently happening by looking for the temp dir
that the stitchit.sampleSplitter created.
Returns True if cropping right now, False otherwise.
"""
t_path = os.path.join(t_path, CROPPED_TEMP_DIR_WILDCARD)
return file_glob_exist(t_path)


def is_data_folder(dirToTest="", verbose=False):
"""is directory "dirToTest" a BakingTray data directory?
i.e. it satisfies the following criteria:
Expand Down
7 changes: 7 additions & 0 deletions btpytools/transferToServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,15 @@ def main():
if check_directories(source_dirs, destination_dir):
sys.exit()

# Bail out if we find any folders at all that have not finished cropping
for t_dir in source_dirs:
if tools.is_currently_cropping(t_dir):
print("Directory '%s' is currently being cropped. QUITTING." % t_dir)
sys.exit()

# Remove trailing slash from data directories that don't contain data sub-directories
for _ii, t_dir in enumerate(source_dirs):

if tools.is_data_folder(t_dir) and not tools.contains_data_folders(t_dir):
# If here, tDIR is a sample folder without sub-folders. If there is a
# trailing slash then we should delete it. Always.
Expand Down
1 change: 0 additions & 1 deletion dist/.gitignore

This file was deleted.

Empty file.
1,048 changes: 1,048 additions & 0 deletions tests/data/cropping_taking_place/acqLog_SM_1099839.txt

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions tests/data/cropping_taking_place/autoROI_settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
main: {borderPixSize: 4.0, medFiltRawImage: 5.0, doTiledMerge: true, tiledMergeThresh: 1.05,
defaultThreshSD: 7.0, reCalcThreshSD_threshold: 10.0, rescaleTo: 50.0}
mainBin: {removeNoise: true, medFiltBW: 5.0, primaryShape: disk, primaryFiltSize: 50.0,
expansionShape: square, doExpansion: true, expansionSize: 600.0}
mainGetBB: {minSizeInSqMicrons: 15000.0}
clipper: {doExtension: true, edgeThreshMicrons: 350.0, growROIbyMicrons: 450.0}
mergeO: {mergeThresh: 1.3}
stackStr: {rollingThreshold: true, nImages: 5.0}
autoThresh: {skipMergeNROIThresh: 10.0, doBinaryExpansion: false, minThreshold: 2.0,
maxThreshold: 12.0, allowMaxExtensionIfFewThreshLeft: true, decreaseThresholdBy: 0.9}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Downsampling SM_1099839
Acquired on: 2021/05/21 17:11:43
Downsampled: 08-Jun-2021 17:29:28
downsample file name: downsampled_stacks/025_micron/ds_SM_1099839_210521_171144_25_25_ch02_chan_2_red.tif

---log---
Begining to downsample:
x/y: 10.953
z: 3.968
Loading and down-sampling x/y by 10.953
Rescaling in z by 3.9683
Done
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Downsampling SM_1099839
Acquired on: 2021/05/21 17:11:43
Downsampled: 08-Jun-2021 17:31:39
downsample file name: downsampled_stacks/025_micron/ds_SM_1099839_210521_171144_25_25_ch03_chan_3_green.tif

---log---
Begining to downsample:
x/y: 10.953
z: 3.968
Loading and down-sampling x/y by 10.953
Rescaling in z by 3.9683
Done
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Downsampling SM_1099839
Acquired on: 2021/05/21 17:11:43
Downsampled: 08-Jun-2021 17:31:39
downsample file name: downsampled_stacks/050_micron/ds_SM_1099839_210521_171144_50_50_ch02_chan_2_red.tif
Rescaled 25 micron volume by 0.50 to write a 50 micron volume
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Downsampling SM_1099839
Acquired on: 2021/05/21 17:11:43
Downsampled: 08-Jun-2021 17:33:47
downsample file name: downsampled_stacks/050_micron/ds_SM_1099839_210521_171144_50_50_ch03_chan_3_green.tif
Rescaled 25 micron volume by 0.50 to write a 50 micron volume
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Acquisition: {acqStartTime: '2021/05/21 17:11:43'}
sample: {ID: XY_1099839, objectiveName: nikon 16x}
mosaic:
sectionStartNum: 1.0
numSections: 208.0
cuttingSpeed: 0.4
cutSize: 16.0
sliceThickness: 0.05
numOverlapZPlanes: 0.0
numOpticalPlanes: 8.0
overlapProportion: 0.1
sampleSize: {X: 8.18, Y: 12.79}
scanmode: 'tiled: auto-ROI'
tilesToRemove: -1.0
CuttingStartPoint: {X: 33.00001, Y: 0.0}
FrontLeft: {X: 18.42387, Y: 11.11418}
StitchingParameters:
VoxelSize: {X: 2.23, Y: 2.335}
lensDistort: {rows: 0.0, cols: 0.0}
affineMat:
- [1.0, -0.011, 0.0]
- [0.0, 1.0, 0.0]
- [0.0, 0.0, 1.0]
scannerSettingsIndex: 3.0
NumTiles: {X: 7.0, Y: 11.0}
Tile: {nRows: 562.0, nColumns: 562.0}
TileStepSize: {X: 1.15198, Y: 1.15198}
VoxelSize: {X: 2.278, Y: 2.278, Z: 6.3}
ScannerSettings:
pixelsPerLine: 562.0
linesPerFrame: 562.0
micronsBetweenOpticalPlanes: 6.3
numOpticalSlices: 8.0
zoomFactor: 1.0
objectiveResolution: 54.7
scannerType: RG
pixEqLinCheckBox: true
scanAngleShiftFast: 0.0
scanAngleShiftSlow: 0.0
slowMult: 1.0
fastMult: 1.0
bidirectionalScan: true
pixelBinFactor: 1.0
sampleRate: 1.2E8
fillFractionSpatial: 0.9000000000000001
FOV_alongColsinMicrons: 1279.98
FOV_alongRowsinMicrons: 1279.98
micronsPerPixel_cols: 2.278
micronsPerPixel_rows: 2.278
framePeriodInSeconds: 0.036
activeChannels: [2.0, 3.0]
averageEveryNframes: 1.0
beamPower: 30.0
powerZAdjust: true
beamPowerLengthConstant: 500.0
powerZAdjustType:
- []
scanMode: resonant
scannerID: ScanImage via SIBT
version: ScanImage(R) Basic 2020.1.4 619cfaf81f on MATLAB 9.7.0.1434023 (R2019b) Update 6
SYSTEM:
ID: brainsaw
xySpeed: 35.0
cutterSide: 1.0
defaultFrontLeft: [12.5, 10.0]
homeZjackOnZeroMove: 1.0
type: bakingtray
version: branch=dev commit=cb5caae318258027f4a41ee123c60aa66413b07a
SLICER: {approachSpeed: 25.0, vibrateRate: 9.0, postCutDelay: 6.0, postCutVibrate: 3.0}
SLACK: {user: '@BrainSaw', hook: 'https://hooks.slack.com/services/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'}
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions tests/test_unit/btpytools_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class btpytools_test:
VALID_SAMPLE_DIR2 = join(DATA_DIR, "valid_sample_directory_02")
CROPPED_ACQ_DIR1 = join(DATA_DIR, "contains_data_subfolders_01")
CROPPED_ACQ_DIR2 = join(DATA_DIR, "contains_data_subfolders_02")
CURRENTLY_CROPPING = join(DATA_DIR, "cropping_taking_place")
7 changes: 7 additions & 0 deletions tests/test_unit/test_btpytools_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def test_has_compressed_raw_data(self):
"""
self.assertTrue(tools.has_compressed_raw_data(self.VALID_SAMPLE_DIR1))

def test_is_cropping(self):
"""
Confirm that can read back that cropping is currently happening
"""
self.assertTrue(tools.is_currently_cropping(self.CURRENTLY_CROPPING))
self.assertFalse(tools.is_currently_cropping(self.VALID_SAMPLE_DIR1))

def test_has_recipe_file(self):
"""
Confirm that VALID_SAMPLE_DIR1 contains a recipe file
Expand Down

0 comments on commit b442a64

Please sign in to comment.