forked from bglnelissen/slideToolkit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslideToolKitTest.py
executable file
·93 lines (80 loc) · 5.25 KB
/
slideToolKitTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print(" slideToolKitTest: test the environment ")
print("")
print("* Version : v1.0.0")
print("")
print("* Last update : 2023-12-15")
print("* Written by : Sander W. van der Laan | s.w.vanderlaan [at] gmail [dot] com")
print("")
print("* Description : This script will test the slideToolKit virtual environment.")
print("")
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
# import required packages
import sys
import time
import arrow
import datetime
# for argument parser
import argparse
import textwrap
# for openslide/openCV
import cv2
import os
import openslide
from openslide import *
# for cellprofiler
import cellprofiler
utc = arrow.utcnow()
# argument parser
parser = argparse.ArgumentParser(
prog='slideToolKitTest',
description='This script will test the slideToolKit virtual environment.',
usage='python3 slideToolKitTest.py [-h/--help] -b/--bdate.',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=textwrap.dedent("Copyright (c) 1979-2023 Sander W. van der Laan | s.w.vanderlaan [at] gmail [dot] com"))
parser.add_argument('-v', '--verbose', help="Will get all available image properties.", default=False, action="store_true")
parser.add_argument('-b','--bdate',help="Your birthdate - format YYYY-MM-DD. Try: 1979-01-13.",
# required=True,
type=datetime.date.fromisoformat) # make sure that the date format is correct, if not the program will stop
args = parser.parse_args()
if not args.bdate:
print("\nOh, computer says no! You must supply correct arguments when running a *** slideToolKitTest ***!")
print("Note that -b/--bdate is required. Try: 1979-01-13.\n")
parser.print_help()
exit()
bd = args.bdate
print("Printing the installed versions.")
print('* Python version: ',sys.version)
print('* OpenSlide version: ',openslide.__version__)
print('* OpenSlide library version: ', openslide.__library_version__)
print('* CellProfiler version: ', cellprofiler.__version__)
print("\nTesting the argument parsing of your birth date.")
print(f"UTC time is = {utc}")
pacific = utc.to('Europe/Vatican') #https://pvlib-python.readthedocs.io/en/stable/timetimezones.html
print(f"European/Amsterdam time is = {pacific}")
bdate_text='You were born on ' + str(bd) # make a string out of the date
birth_date = arrow.get(bdate_text, 'YYYY-MM-DD') # arrow() will get the date from a text
print(f"Your birth date is {birth_date}.")
print(f"You were born {birth_date.humanize()}.")
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print("+ The MIT License (MIT) +")
print("+ Copyright (c) 1979-2023 Sander W. van der Laan | UMC Utrecht, Utrecht, the Netherlands +")
print("+ +")
print("+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +")
print("+ associated documentation files (the \"Software\"), to deal in the Software without restriction, including +")
print("+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +")
print("+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the +")
print("+ following conditions: +")
print("+ +")
print("+ The above copyright notice and this permission notice shall be included in all copies or substantial +")
print("+ portions of the Software. +")
print("+ +")
print("+ THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +")
print("+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO +")
print("+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +")
print("+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +")
print("+ THE USE OR OTHER DEALINGS IN THE SOFTWARE. +")
print("+ +")
print("+ Reference: http://opensource.org. +")
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")