endoreg-db 0.1.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of endoreg-db might be problematic. Click here for more details.

Files changed (121) hide show
  1. endoreg_db/data/__init__.py +14 -0
  2. endoreg_db/data/active_model/data.yaml +3 -0
  3. endoreg_db/data/center/data.yaml +7 -0
  4. endoreg_db/data/endoscope_type/data.yaml +11 -0
  5. endoreg_db/data/endoscopy_processor/data.yaml +45 -0
  6. endoreg_db/data/examination/examinations/data.yaml +17 -0
  7. endoreg_db/data/examination/time/data.yaml +48 -0
  8. endoreg_db/data/examination/time-type/data.yaml +8 -0
  9. endoreg_db/data/examination/type/data.yaml +5 -0
  10. endoreg_db/data/information_source/data.yaml +30 -0
  11. endoreg_db/data/label/label/data.yaml +62 -0
  12. endoreg_db/data/label/label-set/data.yaml +18 -0
  13. endoreg_db/data/label/label-type/data.yaml +7 -0
  14. endoreg_db/data/model_type/data.yaml +7 -0
  15. endoreg_db/data/profession/data.yaml +70 -0
  16. endoreg_db/data/unit/data.yaml +17 -0
  17. endoreg_db/data/unit/length.yaml +31 -0
  18. endoreg_db/data/unit/volume.yaml +26 -0
  19. endoreg_db/data/unit/weight.yaml +31 -0
  20. endoreg_db/forms/__init__.py +2 -0
  21. endoreg_db/forms/settings/__init__.py +8 -0
  22. endoreg_db/forms/unit.py +6 -0
  23. endoreg_db/management/commands/_load_model_template.py +41 -0
  24. endoreg_db/management/commands/delete_legacy_images.py +19 -0
  25. endoreg_db/management/commands/delete_legacy_videos.py +17 -0
  26. endoreg_db/management/commands/extract_legacy_video_frames.py +18 -0
  27. endoreg_db/management/commands/fetch_legacy_image_dataset.py +32 -0
  28. endoreg_db/management/commands/import_legacy_images.py +94 -0
  29. endoreg_db/management/commands/import_legacy_videos.py +76 -0
  30. endoreg_db/management/commands/load_active_model_data.py +45 -0
  31. endoreg_db/management/commands/load_ai_model_data.py +45 -0
  32. endoreg_db/management/commands/load_base_db_data.py +62 -0
  33. endoreg_db/management/commands/load_center_data.py +43 -0
  34. endoreg_db/management/commands/load_endoscope_type_data.py +45 -0
  35. endoreg_db/management/commands/load_endoscopy_processor_data.py +45 -0
  36. endoreg_db/management/commands/load_examination_data.py +75 -0
  37. endoreg_db/management/commands/load_information_source.py +45 -0
  38. endoreg_db/management/commands/load_label_data.py +67 -0
  39. endoreg_db/management/commands/load_profession_data.py +44 -0
  40. endoreg_db/management/commands/load_unit_data.py +46 -0
  41. endoreg_db/management/commands/load_user_groups.py +67 -0
  42. endoreg_db/management/commands/register_ai_model.py +65 -0
  43. endoreg_db/migrations/0001_initial.py +582 -0
  44. endoreg_db/models/__init__.py +53 -0
  45. endoreg_db/models/ai_model/__init__.py +3 -0
  46. endoreg_db/models/ai_model/active_model.py +9 -0
  47. endoreg_db/models/ai_model/model_meta.py +24 -0
  48. endoreg_db/models/ai_model/model_type.py +26 -0
  49. endoreg_db/models/ai_model/utils.py +8 -0
  50. endoreg_db/models/annotation/__init__.py +2 -0
  51. endoreg_db/models/annotation/binary_classification_annotation_task.py +80 -0
  52. endoreg_db/models/annotation/image_classification.py +27 -0
  53. endoreg_db/models/center.py +19 -0
  54. endoreg_db/models/data_file/__init__.py +4 -0
  55. endoreg_db/models/data_file/base_classes/__init__.py +3 -0
  56. endoreg_db/models/data_file/base_classes/abstract_frame.py +51 -0
  57. endoreg_db/models/data_file/base_classes/abstract_video.py +200 -0
  58. endoreg_db/models/data_file/frame.py +45 -0
  59. endoreg_db/models/data_file/report_file.py +88 -0
  60. endoreg_db/models/data_file/video/__init__.py +7 -0
  61. endoreg_db/models/data_file/video/import_meta.py +25 -0
  62. endoreg_db/models/data_file/video/video.py +25 -0
  63. endoreg_db/models/data_file/video_segment.py +107 -0
  64. endoreg_db/models/examination/__init__.py +4 -0
  65. endoreg_db/models/examination/examination.py +26 -0
  66. endoreg_db/models/examination/examination_time.py +27 -0
  67. endoreg_db/models/examination/examination_time_type.py +24 -0
  68. endoreg_db/models/examination/examination_type.py +18 -0
  69. endoreg_db/models/hardware/__init__.py +2 -0
  70. endoreg_db/models/hardware/endoscope.py +44 -0
  71. endoreg_db/models/hardware/endoscopy_processor.py +143 -0
  72. endoreg_db/models/information_source.py +22 -0
  73. endoreg_db/models/label/__init__.py +1 -0
  74. endoreg_db/models/label/label.py +84 -0
  75. endoreg_db/models/legacy_data/__init__.py +3 -0
  76. endoreg_db/models/legacy_data/image.py +34 -0
  77. endoreg_db/models/patient_examination/__init__.py +35 -0
  78. endoreg_db/models/persons/__init__.py +4 -0
  79. endoreg_db/models/persons/examiner/__init__.py +2 -0
  80. endoreg_db/models/persons/examiner/examiner.py +16 -0
  81. endoreg_db/models/persons/examiner/examiner_type.py +2 -0
  82. endoreg_db/models/persons/patient.py +58 -0
  83. endoreg_db/models/persons/person.py +34 -0
  84. endoreg_db/models/persons/portal_user_information.py +29 -0
  85. endoreg_db/models/prediction/__init__.py +2 -0
  86. endoreg_db/models/prediction/image_classification.py +37 -0
  87. endoreg_db/models/prediction/video_prediction_meta.py +244 -0
  88. endoreg_db/models/unit.py +20 -0
  89. endoreg_db/queries/__init__.py +5 -0
  90. endoreg_db/queries/annotations/__init__.py +3 -0
  91. endoreg_db/queries/annotations/legacy.py +159 -0
  92. endoreg_db/queries/get/__init__.py +6 -0
  93. endoreg_db/queries/get/annotation.py +0 -0
  94. endoreg_db/queries/get/center.py +42 -0
  95. endoreg_db/queries/get/model.py +13 -0
  96. endoreg_db/queries/get/patient.py +14 -0
  97. endoreg_db/queries/get/patient_examination.py +20 -0
  98. endoreg_db/queries/get/prediction.py +0 -0
  99. endoreg_db/queries/get/report_file.py +33 -0
  100. endoreg_db/queries/get/video.py +31 -0
  101. endoreg_db/queries/get/video_import_meta.py +0 -0
  102. endoreg_db/queries/get/video_prediction_meta.py +0 -0
  103. endoreg_db/queries/sanity/__init_.py +0 -0
  104. endoreg_db/serializers/__init__.py +10 -0
  105. endoreg_db/serializers/ai_model.py +19 -0
  106. endoreg_db/serializers/annotation.py +17 -0
  107. endoreg_db/serializers/center.py +11 -0
  108. endoreg_db/serializers/examination.py +33 -0
  109. endoreg_db/serializers/frame.py +13 -0
  110. endoreg_db/serializers/hardware.py +21 -0
  111. endoreg_db/serializers/label.py +22 -0
  112. endoreg_db/serializers/patient.py +10 -0
  113. endoreg_db/serializers/prediction.py +15 -0
  114. endoreg_db/serializers/report_file.py +7 -0
  115. endoreg_db/serializers/video.py +27 -0
  116. endoreg_db-0.2.1.dist-info/LICENSE +674 -0
  117. endoreg_db-0.2.1.dist-info/METADATA +27 -0
  118. endoreg_db-0.2.1.dist-info/RECORD +126 -0
  119. endoreg_db-0.1.0.dist-info/METADATA +0 -19
  120. endoreg_db-0.1.0.dist-info/RECORD +0 -10
  121. {endoreg_db-0.1.0.dist-info → endoreg_db-0.2.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,14 @@
1
+ from pathlib import Path
2
+
3
+ DATA_DIR = Path(__file__).parent
4
+
5
+ INFORMATION_DATA_DIR = DATA_DIR / "information_source"
6
+ UNIT_DATA_DIR = DATA_DIR / "unit"
7
+ CENTER_DATA_DIR = DATA_DIR / "center"
8
+ EXAMINATION_DATA_DIR = DATA_DIR / "examination"
9
+ LABEL_DATA_DIR = DATA_DIR / "label"
10
+ MODEL_TYPE_DATA_DIR = DATA_DIR / "model_type"
11
+ ENDOSCOPY_PROCESSOR_DATA_DIR = DATA_DIR / "endoscopy_processor"
12
+ ENDOSCOPE_TYPE_DATA_DIR = DATA_DIR / "endoscope_type"
13
+ ACTIVE_MODEL_DATA_DIR = DATA_DIR / "active_model"
14
+ PROFESSION_DATA_DIR = DATA_DIR / "profession"
@@ -0,0 +1,3 @@
1
+ - model: endoreg_db.active_model
2
+ data:
3
+ - name: "multilabel_image_classification"
@@ -0,0 +1,7 @@
1
+ # center/data.yaml
2
+
3
+ - model: endoreg_db.center
4
+ fields:
5
+ name: "university_hospital_wuerzburg"
6
+ name_de: "Universitätsklinikum Würzburg"
7
+ name_en: "University Hospital Würzburg"
@@ -0,0 +1,11 @@
1
+ - model: endoreg_db.endoscope_type
2
+ fields:
3
+ name: "gastroscope"
4
+ name_de: "Gastroskop"
5
+ name_en: "Gastroscope"
6
+
7
+ - model: endoreg_db.endoscope_type
8
+ fields:
9
+ name: "colonoscope"
10
+ name_de: "Koloskop"
11
+ name_en: "Colonoscope"
@@ -0,0 +1,45 @@
1
+ - model: endoreg_db.endoscopy_processor
2
+ fields:
3
+ name: "olympus_cv_1500"
4
+ image_width: 1920
5
+ image_height: 1080
6
+
7
+ endoscope_image_x: 550
8
+ endoscope_image_y: 0
9
+ endoscope_image_width: 1350
10
+ endoscope_image_height: 1080
11
+
12
+ examination_date_x: 0
13
+ examination_date_y: 0
14
+ examination_date_width: 390
15
+ examination_date_height: 40
16
+
17
+ examination_time_x: 240
18
+ examination_time_y: 7
19
+ examination_time_width: 115
20
+ examination_time_height: 35
21
+
22
+ patient_first_name_x: 80
23
+ patient_first_name_y: 110
24
+ patient_first_name_width: 440
25
+ patient_first_name_height: 33
26
+
27
+ patient_last_name_x: 70
28
+ patient_last_name_y: 83
29
+ patient_last_name_width: 450
30
+ patient_last_name_height: 27
31
+
32
+ patient_dob_x: 70
33
+ patient_dob_y: 180
34
+ patient_dob_width: 160
35
+ patient_dob_height: 50
36
+
37
+ endoscope_type_x: 70
38
+ endoscope_type_y: 630
39
+ endoscope_type_width: 280
40
+ endoscope_type_height: 35
41
+
42
+ endoscope_sn_x: 70
43
+ endoscope_sn_y: 670
44
+ endoscope_sn_width: 280
45
+ endoscope_sn_height: 35
@@ -0,0 +1,17 @@
1
+ - model: report.Examination
2
+ fields:
3
+ name: "colonoscopy"
4
+ name_de: "Koloskopie"
5
+ name_en: "Colonoscopy"
6
+ examination_types: [
7
+ "endoscopy"
8
+ ]
9
+
10
+ - model: report.Examination
11
+ fields:
12
+ name: "gastroscopy"
13
+ name_de: "Gastroskopie"
14
+ name_en: "Gastroscopy"
15
+ examination_types: [
16
+ "endoscopy"
17
+ ]
@@ -0,0 +1,48 @@
1
+ - model: report.ExaminationTime
2
+ fields:
3
+ name: "colonoscopy-total-time"
4
+ name_de: "Koloskopie Zeiten"
5
+ name_en: "Colonoscopy Times"
6
+ time_types: [
7
+ "colonoscopy-time"
8
+ ]
9
+
10
+ # withdrawal-time
11
+ - model: report.ExaminationTime
12
+ fields:
13
+ name: "withdrawal-time"
14
+ name_de: "Withdrawal Time"
15
+ name_en: "Withdrawal Time"
16
+ time_types: [
17
+ "colonoscopy-time"
18
+ ]
19
+
20
+ # cecum-time
21
+ - model: report.ExaminationTime
22
+ fields:
23
+ name: "cecum-time"
24
+ name_de: "Zökum Zeit"
25
+ name_en: "Cecum Time"
26
+ time_types: [
27
+ "colonoscopy-time"
28
+ ]
29
+
30
+ # intubation-time
31
+ - model: report.ExaminationTime
32
+ fields:
33
+ name: "intubation-time"
34
+ name_de: "Intubationszeit"
35
+ name_en: "Intubation Time"
36
+ time_types: [
37
+ "colonoscopy-time"
38
+ ]
39
+
40
+ # colonoscopy-intervention-time
41
+ - model: report.ExaminationTimeType
42
+ fields:
43
+ name: "colonoscopy-intervention-time"
44
+ name_de: "Interventionszeit"
45
+ name_en: "Intervention Time"
46
+ time_types: [
47
+ "colonoscopy-time"
48
+ ]
@@ -0,0 +1,8 @@
1
+ - model:
2
+ fields:
3
+ name: "colonoscopy-time"
4
+ name_de: "Koloskopie-Zeit"
5
+ name_en: "Colonoscopy Time"
6
+ examinations: [
7
+ "colonoscopy"
8
+ ]
@@ -0,0 +1,5 @@
1
+ - model: report.ExaminationType
2
+ fields:
3
+ name: "endoscopy"
4
+ name_de: "Endoskopie"
5
+ name_en: "Endoscopy"
@@ -0,0 +1,30 @@
1
+ - model: endoreg_db.InformationSource
2
+ fields:
3
+ name: treating_physician
4
+ - model: endoreg_db.InformationSource
5
+ fields:
6
+ name: treating_physician_anamnestic
7
+ - model: endoreg_db.InformationSource
8
+ fields:
9
+ name: physicians_note_anamnestic
10
+ - model: endoreg_db.InformationSource
11
+ fields:
12
+ name: patient_anamnestic
13
+ - model: endoreg_db.InformationSource
14
+ fields:
15
+ name: physical_measurement
16
+ - model: endoreg_db.InformationSource
17
+ fields:
18
+ name: family_anamnestic
19
+ - model: endoreg_db.InformationSource
20
+ fields:
21
+ name: physical_examination
22
+ - model: endoreg_db.InformationSource
23
+ fields:
24
+ name: unknown
25
+ - model: endoreg_db.InformationSource
26
+ fields:
27
+ name: prediction
28
+ - model: endoreg_db.InformationSource
29
+ fields:
30
+ name: annotation
@@ -0,0 +1,62 @@
1
+ # labels are: "appendix", "ileocecal_valve", "polyp", "water_jet", "digital_chromo_endoscopy", "instrument", "wound", "blood", "ileum", "low_quality", "clip", "outside"
2
+
3
+ - model: endoreg_db.Label
4
+ fields:
5
+ name: "appendix"
6
+ label_type: "classification"
7
+
8
+ - model: endoreg_db.Label
9
+ fields:
10
+ name: "ileocecal_valve"
11
+ label_type: "classification"
12
+
13
+ - model: endoreg_db.Label
14
+ fields:
15
+ name: "polyp"
16
+ label_type: "classification"
17
+
18
+ - model: endoreg_db.Label
19
+ fields:
20
+ name: "water_jet"
21
+ label_type: "classification"
22
+
23
+ - model: endoreg_db.Label
24
+ fields:
25
+ name: "digital_chromo_endoscopy"
26
+ label_type: "classification"
27
+
28
+ - model: endoreg_db.Label
29
+ fields:
30
+ name: "instrument"
31
+ label_type: "classification"
32
+
33
+ - model: endoreg_db.Label
34
+ fields:
35
+ name: "wound"
36
+ label_type: "classification"
37
+
38
+ - model: endoreg_db.Label
39
+ fields:
40
+ name: "blood"
41
+ label_type: "classification"
42
+
43
+ - model: endoreg_db.Label
44
+ fields:
45
+ name: "ileum"
46
+ label_type: "classification"
47
+
48
+ - model: endoreg_db.Label
49
+ fields:
50
+ name: "low_quality"
51
+ label_type: "classification"
52
+
53
+ - model: endoreg_db.Label
54
+ fields:
55
+ name: "clip"
56
+ label_type: "classification"
57
+
58
+ - model: endoreg_db.Label
59
+ fields:
60
+ name: "outside"
61
+ label_type: "classification"
62
+
@@ -0,0 +1,18 @@
1
+ - model: endoreg_db.LabelSet
2
+ fields:
3
+ name: "multilabel_classification"
4
+ version: 0
5
+ labels: [
6
+ "appendix",
7
+ "ileocecal_valve",
8
+ "polyp",
9
+ "water_jet",
10
+ "digital_chromo_endoscopy",
11
+ "instrument",
12
+ "wound",
13
+ "blood",
14
+ "ileum",
15
+ "low_quality",
16
+ "clip",
17
+ "outside",
18
+ ]
@@ -0,0 +1,7 @@
1
+ - model: endoreg_db.LabelType
2
+ fields:
3
+ name: "classification"
4
+
5
+ - model: endoreg_db.LabelType
6
+ fields:
7
+ name: "object_detection"
@@ -0,0 +1,7 @@
1
+ - model: endoreg_db.model_type
2
+ fields:
3
+ name: "multilabel_classification"
4
+
5
+ - model: endoreg_db.model_type
6
+ fields:
7
+ name: "object_detection"
@@ -0,0 +1,70 @@
1
+ - model: endoreg_db.Profession
2
+ fields:
3
+ name: "nurse"
4
+ name_de: "Pflegekraft"
5
+ name_en: "Nurse"
6
+ description: "Not further specified nurse"
7
+
8
+ # endoscopy nurse
9
+ - model: endoreg_db.Profession
10
+ fields:
11
+ name: "endoscopy-nurse"
12
+ name_de: "Pflegekraft (Endoskopie)"
13
+ name_en: "Endoscopy nurse"
14
+ description: "Endoscopy nurse"
15
+
16
+ - model: endoreg_db.Profession
17
+ fields:
18
+ name: "physician"
19
+ name_de: "Arzt"
20
+ name_en: "Physician"
21
+ description: "Not further specified doctor"
22
+
23
+ # Physician in training (gastroenterology)
24
+ - model: endoreg_db.Profession
25
+ fields:
26
+ name: "physician-in-training-gastroenterology"
27
+ name_de: "Arzt in Weiterbildung Gastroenterologie"
28
+ name_en: "Physician in training (gastroenterology)"
29
+ description: "Physician in training (gastroenterology)"
30
+
31
+ # Physician in training (internal medicine)
32
+ - model: endoreg_db.Profession
33
+ fields:
34
+ name: "physician-in-training-internal-medicine"
35
+ name_de: "Arzt in Weiterbildung Innere Medizin"
36
+ name_en: "Physician in training (internal medicine)"
37
+ description: "Physician in training (internal medicine)"
38
+
39
+ # Physician in training (general surgery)
40
+ - model: endoreg_db.Profession
41
+ fields:
42
+ name: "physician-in-training-general-surgery"
43
+ name_de: "Arzt in Weiterbildung Allgemeinchirurgie"
44
+ name_en: "Physician in training (general surgery)"
45
+ description: "Physician in training (general surgery)"
46
+
47
+ # Physician (Internal Medicine)
48
+ - model: endoreg_db.Profession
49
+ fields:
50
+ name: "physician-internal-medicine"
51
+ name_de: "Arzt Innere Medizin"
52
+ name_en: "Physician (Internal Medicine)"
53
+ description: "Physician (Internal Medicine)"
54
+
55
+ # Physician (Gastroenterology)
56
+ - model: endoreg_db.Profession
57
+ fields:
58
+ name: "physician-gastroenterology"
59
+ name_de: "Arzt Gastroenterologie"
60
+ name_en: "Physician (Gastroenterology)"
61
+ description: "Physician (Gastroenterology)"
62
+
63
+ # Physician (General Surgery)
64
+ - model: endoreg_db.Profession
65
+ fields:
66
+ name: "physician-general-surgery"
67
+ name_de: "Arzt Allgemeinchirurgie"
68
+ name_en: "Physician (General Surgery)"
69
+ description: "Physician (General Surgery)"
70
+
@@ -0,0 +1,17 @@
1
+ - model: endoreg_db.Unit
2
+ fields:
3
+ name: "liters-per-minute"
4
+ abbreviation: "l/min"
5
+ name_de: "Liter pro Minute"
6
+ name_en: "Liters per Minute"
7
+ description: "liters per minute"
8
+
9
+
10
+ # kilowatt-hours
11
+ - model: endoreg_db.Unit
12
+ fields:
13
+ name: "kilowatt-hours"
14
+ abbreviation: "kWh"
15
+ name_de: "Kilowattstunden"
16
+ name_en: "Kilowatt-hours"
17
+ description: "kilowatt-hours"
@@ -0,0 +1,31 @@
1
+ - model: endoreg_db.Unit
2
+ fields:
3
+ name: "millimeter"
4
+ abbreviation: "mm"
5
+ name_de: "Millimeter"
6
+ name_en: "Millimeter"
7
+ description: "millimeters"
8
+
9
+ - model: endoreg_db.Unit
10
+ fields:
11
+ name: "centimeter"
12
+ abbreviation: "cm"
13
+ name_de: "Zentimeter"
14
+ name_en: "Centimeter"
15
+ description: "centimeters"
16
+
17
+ - model: endoreg_db.Unit
18
+ fields:
19
+ name: "meter"
20
+ abbreviation: "m"
21
+ name_de: "Meter"
22
+ name_en: "Meter"
23
+ description: "meters"
24
+
25
+ - model: endoreg_db.Unit
26
+ fields:
27
+ name: "kilometer"
28
+ abbreviation: "km"
29
+ name_de: "Kilometer"
30
+ name_en: "Kilometer"
31
+ description: "kilometers"
@@ -0,0 +1,26 @@
1
+ # Units/data.yaml
2
+
3
+ - model: endoreg_db.Unit
4
+ fields:
5
+ name: "milliliter"
6
+ abbreviation: "ml"
7
+ name_de: "Milliliter"
8
+ name_en: "Milliliter"
9
+ description: "milliliters"
10
+
11
+ - model: endoreg_db.Unit
12
+ fields:
13
+ name: "liter"
14
+ abbreviation: "l"
15
+ name_de: "Liter"
16
+ name_en: "Liter"
17
+ description: "liters"
18
+
19
+ # cubic_meter
20
+ - model: endoreg_db.Unit
21
+ fields:
22
+ name: "cubic_meter"
23
+ abbreviation: "m³"
24
+ name_de: "Kubikmeter"
25
+ name_en: "Cubic Meter"
26
+ description: "cubic meters"
@@ -0,0 +1,31 @@
1
+ - model: endoreg_db.Unit
2
+ fields:
3
+ name: "microgram"
4
+ abbreviation: "µg"
5
+ name_de: "Mikrogramm"
6
+ name_en: "Microgram"
7
+ description: "micrograms"
8
+
9
+ - model: endoreg_db.Unit
10
+ fields:
11
+ name: "milligram"
12
+ abbreviation: "mg"
13
+ name_de: "Milligramm"
14
+ name_en: "Milligram"
15
+ description: "milligrams"
16
+
17
+ - model: endoreg_db.Unit
18
+ fields:
19
+ name: "gram"
20
+ abbreviation: "g"
21
+ name_de: "Gramm"
22
+ name_en: "Gram"
23
+ description: "grams"
24
+
25
+ - model: endoreg_db.Unit
26
+ fields:
27
+ name: "kilogram"
28
+ abbreviation: "kg"
29
+ name_de: "Kilogramm"
30
+ name_en: "Kilogram"
31
+ description: "kilograms"
@@ -0,0 +1,2 @@
1
+ from .unit import Unit
2
+ from .settings import ActiveModelForm
@@ -0,0 +1,8 @@
1
+ # forms.py
2
+ from django import forms
3
+ from endoreg_db.models import ActiveModel
4
+
5
+ class ActiveModelForm(forms.ModelForm):
6
+ class Meta:
7
+ model = ActiveModel
8
+ fields = ["model_meta"] # Or list the specific fields you want to include in the form.
@@ -0,0 +1,6 @@
1
+ from django import forms
2
+ from ..models import Unit
3
+
4
+ class UnitForm(forms.Form):
5
+ class Meta:
6
+ model = Unit
@@ -0,0 +1,41 @@
1
+ from django.conf import settings
2
+ from django.core.management.base import BaseCommand
3
+ from reports.models import Intervention, InterventionType # Replace 'your_app_name' with the actual app name
4
+ import os
5
+ from reports.dataloader_utils import load_model_data
6
+
7
+ SOURCE_DIR = None # e.g. settings.DATA_DIR_INTERVENTION
8
+
9
+ IMPORT_MODELS = [ # string as model key, serves as key in IMPORT_METADATA
10
+ ]
11
+
12
+ IMPORT_METADATA = {
13
+ # "": { # same as model name in "import models", e.g. "Intervention"
14
+ # "dir": os.path.join(SOURCE_DIR,""), # e.g. "interventions"
15
+ # "model": None, # e.g. Intervention
16
+ # "foreign_keys": [], # e.g. ["intervention_types"]
17
+ # "foreign_key_models": [] # e.g. [InterventionType]
18
+ # },
19
+ }
20
+
21
+ class Command(BaseCommand):
22
+ help = """Load all .yaml files in the data/intervention directory
23
+ into the Intervention and InterventionType model"""
24
+
25
+ def add_arguments(self, parser):
26
+ parser.add_argument(
27
+ '--verbose',
28
+ action='store_true',
29
+ help='Display verbose output',
30
+ )
31
+
32
+ def handle(self, *args, **options):
33
+ verbose = options['verbose']
34
+ for model_name in IMPORT_MODELS:
35
+ _metadata = IMPORT_METADATA[model_name]
36
+ load_model_data(
37
+ self,
38
+ model_name,
39
+ _metadata,
40
+ verbose
41
+ )
@@ -0,0 +1,19 @@
1
+ # django command to delete all LegacyImage objects
2
+
3
+ from django.core.management.base import BaseCommand, CommandError
4
+ from endoreg_db.models import LegacyImage
5
+ from tqdm import tqdm
6
+
7
+ class Command(BaseCommand):
8
+ help = 'Deletes all LegacyImage objects including the linked files (legacy_image.image)'
9
+
10
+ def handle(self, *args, **options):
11
+ legacy_images = LegacyImage.objects.all()
12
+
13
+ for legacy_image in tqdm(legacy_images):
14
+ legacy_image.image.delete()
15
+ legacy_image.delete()
16
+
17
+ self.stdout.write(self.style.SUCCESS('Successfully deleted all LegacyImage objects and linked image files'))
18
+
19
+
@@ -0,0 +1,17 @@
1
+ # Django command to fetch all LegacyVideo objects, delete the associated file and delete the object from the database
2
+
3
+ from endoreg_db.models.data_file.video import LegacyVideo
4
+ from tqdm import tqdm
5
+ from django.core.management.base import BaseCommand
6
+
7
+ class Command(BaseCommand):
8
+ """
9
+ Deletes all LegacyVideos in the database.
10
+ """
11
+ help = 'Deletes all LegacyVideos in the database.'
12
+
13
+ def handle(self, *args, **options):
14
+ videos = LegacyVideo.objects.all()
15
+ for video in tqdm(videos):
16
+ video.file.delete()
17
+ video.delete()
@@ -0,0 +1,18 @@
1
+ # Django Command to:
2
+ # fetch all LegacyVideos and extract frames from them
3
+ # track progress for all videos and for each video with tqdm
4
+
5
+ from endoreg_db.models.data_file.video import LegacyVideo
6
+ from tqdm import tqdm
7
+ from django.core.management.base import BaseCommand
8
+
9
+ class Command(BaseCommand):
10
+ """
11
+ Extracts frames from all LegacyVideos in the database.
12
+ """
13
+ help = 'Extracts frames from all LegacyVideos in the database.'
14
+
15
+ def handle(self, *args, **options):
16
+ videos = LegacyVideo.objects.all()
17
+ for video in tqdm(videos):
18
+ video.extract_all_frames()
@@ -0,0 +1,32 @@
1
+ # command to fetch the legacy dataset and save it to a json file.
2
+ from django.core.management.base import BaseCommand, CommandError
3
+ from endoreg_db.queries import generate_legacy_dataset_output
4
+ import json
5
+
6
+ LABELSET_NAME = "multilabel_classification"
7
+ LABELSET_VERSION = 0
8
+
9
+ class Command(BaseCommand):
10
+ help = 'Fetches the legacy dataset and saves it to a jsonl file'
11
+
12
+ def handle(self, *args, **options):
13
+ output, labelset = generate_legacy_dataset_output(LABELSET_NAME, LABELSET_VERSION)
14
+ # output is a list of dicts, each dict is an image
15
+ labels_in_order = labelset.get_labels_in_order()
16
+
17
+ # write to file
18
+ with open('legacy_dataset.jsonl', 'w') as f:
19
+ for img_dict in output:
20
+ f.write(json.dumps(img_dict) + '\n')
21
+
22
+
23
+ _dict = {
24
+ "labels": [label.name for label in labels_in_order],
25
+ "name": LABELSET_NAME,
26
+ "version": LABELSET_VERSION
27
+ }
28
+
29
+ with open('legacy_dataset_info.json', 'w') as f:
30
+ f.write(json.dumps(_dict))
31
+
32
+ self.stdout.write(self.style.SUCCESS('Successfully fetched and saved the legacy dataset'))