Skip to content

Commit 16969d8

Browse files
Copilotbeniroquai
andcommitted
Fix trailing whitespace and basic formatting issues
Co-authored-by: beniroquai <[email protected]>
1 parent 5a99a4b commit 16969d8

File tree

256 files changed

+3259
-3259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+3259
-3259
lines changed

imswitch/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
jupyternotebookurl = ""
88
__argparse__ = None
99

10-
'''
11-
These are flags to ensure headless operation and side-loading of the config file
10+
'''
11+
These are flags to ensure headless operation and side-loading of the config file
1212
'''
1313
IS_HEADLESS = False
1414
DEFAULT_SETUP_FILE = None

imswitch/__main__.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ def main(is_headless:bool=None, default_config:str=None, http_port:int=None, soc
99
data_folder: str=None, scan_ext_data_folder:bool=None, ext_drive_mount:str=None):
1010
'''
1111
is_headless: bool => start with or without qt
12-
default_config: str => path to the config file
12+
default_config: str => path to the config file
1313
http_port: int => port number (default: 8001)
1414
socket_port: int => port number (default: 8002)
1515
ssl: bool => use ssl (default: True)
1616
config_folder: str => path to the config folder (default: None, pointing to Documents/ImSwitch)
1717
data_folder: str => path to the data folder (default: None, pointing to Documents/ImSwitchConfig)
1818
scan_ext_data_folder: bool => if True, we will scan the ext_drive_mount for usb drives and use this for data storage
1919
ext_drive_mount: str => path to the external drive mount point (default: None, optionally pointing to e.g. /Volumes or /media)
20-
21-
22-
20+
21+
22+
2323
To start imswitch in headless using the arguments, you can call the main file with the following arguments:
2424
python main.py --headless or
2525
python -m imswitch --headless 1 --config-file example_virtual_microscope.json --config-folder /Users/bene/Downloads --scan-ext-drive-mount true --ext-data-folder ~/Downloads --ext-drive-mount /Volumes
@@ -40,37 +40,37 @@ def main(is_headless:bool=None, default_config:str=None, http_port:int=None, soc
4040
parser.add_argument('--http-port', dest='http_port', type=int, default=8001,
4141
help='specify http port')
4242

43-
# specify socket port
43+
# specify socket port
4444
parser.add_argument('--socket-port', dest='socket_port', type=int, default=8002,
4545
help='specify socket port')
4646
# specify ssl
4747
parser.add_argument('--no-ssl', dest='ssl', default=True, action='store_false',
4848
help='specify ssl')
49-
49+
5050
# specify the config folder (e.g. if running from a different location / container)
5151
parser.add_argument('--config-folder', dest='config_folder', type=str, default=None,
5252
help='specify config folder')
53-
54-
parser.add_argument('--ext-data-folder', dest='data_folder', type=str, default=None,
53+
54+
parser.add_argument('--ext-data-folder', dest='data_folder', type=str, default=None,
5555
help='point to a folder to store the data. This is the default location for the data folder. If not specified, the default location will be used.')
5656

5757
parser.add_argument('--scan-ext-drive-mount', dest='scan_ext_data_folder', default=False, action='store_true',
5858
help='scan the external mount (linux only) if we have a USB drive to save to')
59-
59+
6060
parser.add_argument('--ext-drive-mount', dest='ext_drive_mount', type=str, default=None,
6161
help='specify the external drive mount point (e.g. /Volumes or /media)')
62-
63-
64-
62+
63+
64+
6565
args = parser.parse_args()
66-
67-
imswitch.IS_HEADLESS = args.headless # if True, no QT will be loaded
66+
67+
imswitch.IS_HEADLESS = args.headless # if True, no QT will be loaded
6868
imswitch.__httpport__ = args.http_port # e.g. 8001
6969
imswitch.__ssl__ = args.ssl # if True, ssl will be used (e.g. https)
7070
imswitch.__socketport__ = args.socket_port # e.g. 8002
71-
71+
7272
if type(args.config_file)==str and args.config_file.find("json")>=0: # e.g. example_virtual_microscope.json
73-
imswitch.DEFAULT_SETUP_FILE = args.config_file
73+
imswitch.DEFAULT_SETUP_FILE = args.config_file
7474
if args.config_folder and os.path.isdir(args.config_folder):
7575
imswitch.DEFAULT_CONFIG_PATH = args.config_folder # e.g. /Users/USER/ in case an alternative path is used
7676
if args.data_folder and os.path.isdir(args.data_folder):
@@ -79,7 +79,7 @@ def main(is_headless:bool=None, default_config:str=None, http_port:int=None, soc
7979
imswitch.SCAN_EXT_DATA_FOLDER = args.scan_ext_data_folder
8080
if args.ext_drive_mount:
8181
imswitch.EXT_DRIVE_MOUNT = args.ext_drive_mount
82-
82+
8383
except Exception as e:
8484
print(e)
8585
pass
@@ -123,7 +123,7 @@ def main(is_headless:bool=None, default_config:str=None, http_port:int=None, soc
123123
logger.info(f'Config file: {imswitch.DEFAULT_SETUP_FILE}')
124124
logger.info(f'Config folder: {imswitch.DEFAULT_CONFIG_PATH}')
125125
logger.info(f'Data folder: {imswitch.DEFAULT_DATA_PATH}')
126-
126+
127127
if imswitch.IS_HEADLESS:
128128
app = None
129129
else:
@@ -151,7 +151,7 @@ def main(is_headless:bool=None, default_config:str=None, http_port:int=None, soc
151151
# connect the different controllers through the communication channel
152152
moduleCommChannel = ModuleCommunicationChannel()
153153

154-
# only create the GUI if necessary
154+
# only create the GUI if necessary
155155
if not imswitch.IS_HEADLESS:
156156
from imswitch.imcommon.view import MultiModuleWindow, ModuleLoadErrorView
157157
multiModuleWindow = MultiModuleWindow('ImSwitch')
@@ -178,15 +178,15 @@ def main(is_headless:bool=None, default_config:str=None, http_port:int=None, soc
178178
# The displayed module name will be the module's __title__, or alternatively its ID if
179179
# __title__ is not set
180180
moduleName = modulePkg.__title__ if hasattr(modulePkg, '__title__') else moduleId
181-
# we load all the controllers, managers and widgets here:
181+
# we load all the controllers, managers and widgets here:
182182
try:
183183
view, controller = modulePkg.getMainViewAndController(
184184
moduleCommChannel=moduleCommChannel,
185185
multiModuleWindowController=multiModuleWindowController,
186186
moduleMainControllers=moduleMainControllers
187187
)
188188
logger.info(f'initialize module {moduleId}')
189-
189+
190190
except Exception as e:
191191
logger.error(f'Failed to initialize module {moduleId}')
192192
logger.error(e)
@@ -197,11 +197,11 @@ def main(is_headless:bool=None, default_config:str=None, http_port:int=None, soc
197197
multiModuleWindow.addModule(moduleId, moduleName, ModuleLoadErrorView(e))
198198
else:
199199
# Add module to window
200-
if not imswitch.IS_HEADLESS:
200+
if not imswitch.IS_HEADLESS:
201201
multiModuleWindow.addModule(moduleId, moduleName, view)
202202
moduleMainControllers[moduleId] = controller
203-
204-
# in case of the imnotebook, spread the notebook url
203+
204+
# in case of the imnotebook, spread the notebook url
205205
if moduleId == 'imnotebook':
206206
imswitch.jupyternotebookurl = controller.webaddr
207207

imswitch/_data/images/calculatewellplatepositions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#%% compute the positions of wells in a wellplate
1+
#%% compute the positions of wells in a wellplate
22

3-
import json
3+
import json
44
import numpy as np
55
import matplotlib.pyplot as plt
66
import matplotlib.patches as patches
77

88
#%%
9-
# read in the json file with the coordinates
9+
# read in the json file with the coordinates
1010
pixelsize_eff = .31 # um from camera
1111
overlap = 0.75 # 25% overlap
1212
n_pix_x, n_pix_y = 4000,3000
@@ -29,7 +29,7 @@
2929
n_tiles_x = int(2*radius/fov_physical_x) # number of pixels in the radius
3030
n_tiles_y = int(2*radius/fov_physical_y) # number of pixels in the radius
3131

32-
# % create xx/yy meshgrid
32+
# % create xx/yy meshgrid
3333
xx,yy = np.meshgrid(fov_physical_x*np.arange(-n_tiles_x//2,n_tiles_x//2)+1,fov_physical_y*np.arange(-n_tiles_y//2,n_tiles_y//2)+1)
3434
circle = ((xx)**2+(yy)**2) < radius**2
3535

@@ -44,7 +44,7 @@
4444

4545
for well in data['ScanParameters']['wells']:
4646
center_x, center_y = well['positionX'], well['positionY']
47-
47+
4848
if 0:
4949
plt.plot(well_scan_locations[0]+center_x,well_scan_locations[1]+center_y,'r.')
5050
plt.plot(center_x,center_y,'b.')
@@ -54,10 +54,10 @@
5454
plt.gca().add_patch(rect)
5555
plt.show()
5656

57-
5857

5958

60-
59+
60+
6161
# %%
6262

6363
# %%

imswitch/_data/images/samplelayouts/generateWellplateJSON.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
import os
2+
import os
33

44
def generate_wellplate_json(
55
name,
@@ -30,11 +30,11 @@ def generate_wellplate_json(
3030
wells.append({
3131
"wellID": f"{chr(65+j)}{i+1}",
3232
"positionX": well_x,
33-
"positionY": well_y,
33+
"positionY": well_y,
3434
"positionXpx": well_x * pixel_image_x / phys_dim_x,
3535
"positionYpx": well_y * pixel_image_y / phys_dim_y,
36-
"idX": i,
37-
"idY": j,
36+
"idX": i,
37+
"idY": j,
3838
"idN": idN,
3939
"positionXmin": well_x - well_radius,
4040
"positionXmax": well_x + well_radius,
@@ -62,9 +62,9 @@ def generate_wellplate_json(
6262
return data
6363

6464
imageFilePaths = [
65-
'images/samplelayouts/6wellplate_1509x1010.png',
66-
'images/samplelayouts/12wellplate_1509x1010.png',
67-
'images/samplelayouts/24wellplate_1509x1010.png',
65+
'images/samplelayouts/6wellplate_1509x1010.png',
66+
'images/samplelayouts/12wellplate_1509x1010.png',
67+
'images/samplelayouts/24wellplate_1509x1010.png',
6868
'images/samplelayouts/96wellplate_1509x1010.png']
6969

7070
parameterPerImage = [
@@ -81,7 +81,7 @@ def generate_wellplate_json(
8181
"center_x": 63.85,
8282
"center_y": 42.75,
8383
"well_spacing_x": 31,
84-
"well_spacing_y": 0,
84+
"well_spacing_y": 0,
8585
"well_radius": 10,
8686
"filePath": 'images/samplelayouts/4slidecarrier_1509x1010.png'
8787
},
@@ -98,7 +98,7 @@ def generate_wellplate_json(
9898
"center_x": 63.85,
9999
"center_y": 42.75,
100100
"well_spacing_x": 39,
101-
"well_spacing_y": 39,
101+
"well_spacing_y": 39,
102102
"well_radius": 17.5,
103103
"filePath": 'images/samplelayouts/6wellplate_1509x1010.png'
104104
},
@@ -133,7 +133,7 @@ def generate_wellplate_json(
133133
"center_y": 42.75,
134134
"well_spacing_x": 18.9,
135135
"well_spacing_y": 18.9,
136-
"well_radius": 6.5,
136+
"well_radius": 6.5,
137137
"filePath": 'images/samplelayouts/24wellplate_1509x1010.png'
138138
},
139139
{
@@ -156,7 +156,7 @@ def generate_wellplate_json(
156156
]
157157

158158
for iWellplate in parameterPerImage:
159-
159+
160160
wellplate_json = generate_wellplate_json(
161161
name = iWellplate['name'],
162162
pixel_image_x = iWellplate['pixel_image_x'],
@@ -175,7 +175,7 @@ def generate_wellplate_json(
175175
well_radius = iWellplate['well_radius']
176176
)
177177
basePath = 'imswitch/_data/images/'
178-
178+
179179
json_file_path = os.path.join(basePath, f"{iWellplate['name'].replace(' ', '_').lower()}.json")
180180

181181
with open(json_file_path, "w") as file:

imswitch/_data/user_defaults/scripts/lightsheet_psf_ac.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
for i in range(num_steps):
3434
# Relative move, step size 5
3535
api.imcontrol.movePositioner(positionerName, "X", step_size, False, True)
36-
36+
3737
# Wait 50ms before proceeding
3838
time.sleep(1)
39-
39+
4040
# Capture image
4141
image = api.imcontrol.snapImage(True, False)
4242
mImageList.append(image)
43-
43+
4444
# Optional: Print current position
4545
current_position = start_X + (i + 1) * step_size
4646
print(f"Image captured at position X = {current_position}.")

imswitch/_data/user_defaults/scripts/uc2_move_positoinlist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
for iy in range(2):
5959
mPos = (ix*xDim*mOverlap+58000,
6060
iy*yDim*mOverlap+23000)
61-
61+
6262
api.imcontrol.movePositioner(positionerName, "XY", mPos, True, True)
6363
time.sleep(0.5)
6464
# api.imcontrol.snapImageToPath(str(ix)+"_"+str(iy))
@@ -97,7 +97,7 @@
9797
#iPos = 0
9898
#for position in positions:
9999
# posX, posY, posZ = position
100-
100+
101101
# api.imcontrol.movePositioner(positionerName, "X", posX, True, True)
102102
# api.imcontrol.movePositioner(positionerName, "Y", posY, True, True)
103103
# api.imcontrol.movePositioner(positionerName, "Z", posZ, True, True)

imswitch/imcommon/applaunch.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ipykernel.embed import embed_kernel # pip install ipykernel
99

1010
from .model import dirtools, pythontools, initLogger
11-
from imswitch.imcommon.framework import Signal, Thread
11+
from imswitch.imcommon.framework import Signal, Thread
1212
from imswitch import IS_HEADLESS
1313
if not IS_HEADLESS:
1414
from qtpy import QtCore, QtGui, QtWidgets
@@ -49,7 +49,7 @@ def prepareApp():
4949
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_DisableHighDpiScaling, True) # proper scaling on Mac?
5050
#QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
5151
# https://stackoverflow.com/questions/72131093/pyqt5-qwebengineview-doesnt-load-url
52-
# The following element (sandbox) is to keep the app from crashing when using QWebEngineView
52+
# The following element (sandbox) is to keep the app from crashing when using QWebEngineView
5353
app = QtWidgets.QApplication(['', '--no-sandbox'])
5454
app.setWindowIcon(QtGui.QIcon(os.path.join(dirtools.DataFileDirs.Root, 'icon.png')))
5555
app.setStyleSheet(getBaseStyleSheet())
@@ -64,7 +64,7 @@ def launchApp(app, mainView, moduleMainControllers):
6464
if IS_HEADLESS:
6565
"""We won't have any GUI, so we don't need to prepare the app."""
6666
# Keep python running
67-
# embed_kernel() # TODO: This should be non-blocking!
67+
# embed_kernel() # TODO: This should be non-blocking!
6868
tDiskCheck = time.time()
6969
while True: # TODO: have webserver signal somehow?
7070
try:
@@ -74,11 +74,11 @@ def launchApp(app, mainView, moduleMainControllers):
7474
# if the storage is full or the user presses Ctrl+C, we want to stop the experiment
7575
moduleMainControllers.mapping["imcontrol"]._ImConMainController__commChannel.sigExperimentStop.emit()
7676
tDiskCheck = time.time()
77-
77+
7878
except KeyboardInterrupt:
7979
exitCode = 0
8080
break
81-
81+
8282
else:
8383
# Show app
8484
if mainView is not None:

imswitch/imcommon/controller/CheckUpdatesController.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import datetime
1111

1212
from imswitch import IS_HEADLESS, __version__
13-
from imswitch.imcommon.framework import Signal, Thread
13+
from imswitch.imcommon.framework import Signal, Thread
1414
from imswitch.imcommon.model import initLogger
1515
from .basecontrollers import WidgetController
1616

@@ -72,7 +72,7 @@ def run(self):
7272
## attempting to downloda the current ImSwitch version
7373
downloadURL = releaseResponse.json()['assets'][0]['browser_download_url']
7474
self.__logger.debug("We are downloading the software from: "+downloadURL)
75-
75+
7676
## inplace replacement won't work I guess? => seems to work
7777
def dlImSwitch(downloadURL, fileName):
7878
resultDL = urllib.request.urlretrieve(downloadURL, fileName)
@@ -84,7 +84,7 @@ def dlImSwitch(downloadURL, fileName):
8484
mThread.join()
8585

8686
# make a backup copy of the file
87-
if os.path.isfile(ImSwitchExeFilename):
87+
if os.path.isfile(ImSwitchExeFilename):
8888
self.__logger.debug("Renaming old ImSwitch.exe file")
8989
tz = datetime.timezone.utc
9090
ft = "%Y-%m-%dT%H-%M-%S"
@@ -97,8 +97,8 @@ def dlImSwitch(downloadURL, fileName):
9797
self.__logger.debug("Download successful!")
9898
self.sigNewVersionShowInfo.emit("Download successful! Please restart ImSwitch. ")
9999

100-
101-
100+
101+
102102
else:
103103
self.sigNoUpdate.emit()
104104
else:
@@ -117,8 +117,8 @@ def dlImSwitch(downloadURL, fileName):
117117
#self.sigFailed.emit()
118118
self.sigNewVersionShowInfo.emit("Updating failed. "+str(e))
119119

120-
121-
120+
121+
122122
def getCurrentCommitDate(self):
123123
return str(subprocess.check_output(['git', 'log', '-n', '1', '--pretty=tformat:%h-%ad', '--date=short']).strip()).split("-")[-3:]
124124

0 commit comments

Comments
 (0)