Skip to content

Commit

Permalink
add folder level selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Gahhh committed Nov 26, 2023
1 parent 05fa35b commit c87cded
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 52 deletions.
78 changes: 43 additions & 35 deletions docs/trial_folder_structure/LARK.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"rt_dose_pres": {
"path": "/{clinical_trial}/{test_centre}/Patient Plans/Patient {centre_patient_no}/Dose/",
"display_name": "RT Dose (prescription level)",
"field_type": "file",
"field_type": "folder",
"level": "prescription",
"allowed": [
"application/dicom"
Expand All @@ -31,15 +31,15 @@
"rt_plan_pres": {
"path": "/{clinical_trial}/{test_centre}/Patient Plans/Patient {centre_patient_no}/Plan/",
"display_name": "RT Plan (prescription level)",
"field_type": "file",
"field_type": "folder",
"level": "prescription",
"allowed": [
"application/dicom"
],
"file_name": []
},
"rt_structure_pres": {
"path": "/{clinical_trial}/{test_centre}/Patient Structure Sets/Patient {centre_patient_no}/{fraction_name}/",
"path": "/{clinical_trial}/{test_centre}/Patient Structure Sets/Patient {centre_patient_no}/",
"display_name": "RT Structure (prescription level)",
"field_type": "folder",
"level": "fraction",
Expand All @@ -50,7 +50,7 @@
"planned_dvh_pres": {
"path": "/{clinical_trial}/{test_centre}/Dose Reconstruction/DVH/Patient {centre_patient_no}/",
"display_name": "Planned DVH (prescription level)",
"field_type": "file",
"field_type": "folder",
"level": "prescription",
"allowed": [
"text/plain",
Expand All @@ -60,14 +60,14 @@
"planned_dicom_pres": {
"path": "/{clinical_trial}/{test_centre}/Dose Reconstruction/DICOM/Patient {centre_patient_no}/",
"display_name": "Planned DICOM (prescription level)",
"field_type": "file",
"field_type": "folder",
"level": "prescription",
"allowed": ["application/dicom"]
},
"centroid_pres": {
"path": "/{clinical_trial}/{test_centre}/Patient Files/Patient {centre_patient_no}/",
"display_name": "Centroid (prescription level)",
"field_type": "file",
"field_type": "folder",
"level": "prescription",
"allowed": [
"text/plain"
Expand All @@ -88,36 +88,44 @@
"rt_dose_fraction": {
"path": "/{clinical_trial}/{test_centre}/Patient Plans/Patient {centre_patient_no}/Dose/",
"display_name": "RT Dose (fraction level)",
"field_type": "file",
"field_type": "folder",
"level": "fraction",
"allowed": [
"application/dicom"
],
"file_name": []
},
"rt_plan_fraction": {
"path": "",
"display_name": "",
"field_type": "file",
"level": "",
"allowed": []
"path": "/{clinical_trial}/{test_centre}/Patient Plans/Patient {centre_patient_no}/Plan/",
"display_name": "RT Dose (fraction level)",
"field_type": "folder",
"level": "fraction",
"allowed": [
"application/dicom"
],
"file_name": []
},
"rt_structure_fraction": {
"path": "",
"display_name": "",
"field_type": "file",
"level": "",
"allowed": []
"path": "/{clinical_trial}/{test_centre}/Patient Structure Sets/Patient {centre_patient_no}/",
"display_name": "RT Structure (fraction level)",
"field_type": "folder",
"level": "fraction",
"allowed": [
"application/dicom"
],
"file_name": []
},
"centroid_fraction": {
"path": "/{clinical_trial}/{test_centre}/Patient Files/Patient {centre_patient_no}/",
"display_name": "Centroid (fraction level)",
"field_type": "file",
"field_type": "folder",
"level": "fraction",
"allowed": [
"text/plain",
"text/csv",
"text/xlsx"
"application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.oasis.opendocument.spreadsheet"
],
"file_name": [
"Centroid"
Expand All @@ -126,7 +134,7 @@
"KIM threshold": {
"path": "/{clinical_trial}/{test_centre}/Patient Files/Patient {centre_patient_no}/",
"display_name": "KIM threshold (fraction level)",
"field_type": "file",
"field_type": "folder",
"level": "fraction",
"allowed": ["text/plain"]
},
Expand All @@ -152,12 +160,11 @@
"image/his",
"image/jpg",
"image/png",
"image/dicom",
"application/dicom",
"application/octet-stream",
"text/plain",
"text/xml"
"text/csv",
"text/xml",
"text/csv"
]
},
"mv_images_path": {
Expand All @@ -176,14 +183,14 @@
"application/dicom",
"application/octet-stream",
"text/plain",
"text/xml"
"text/csv",
"text/xml",
"text/csv"
]
},
"metrics_path": {
"path": "/{clinical_trial}/{test_centre}/Triangulation/Patient {centre_patient_no}/",
"display_name": "Metrics",
"field_type": "file",
"field_type": "folder",
"level": "fraction",
"allowed": [
"text/plain",
Expand All @@ -196,7 +203,7 @@
"triangulation_path": {
"path": "/{clinical_trial}/{test_centre}/Triangulation/Patient {centre_patient_no}/",
"display_name": "Triangulation Files",
"field_type": "file",
"field_type": "folder",
"level": "fraction",
"allowed": [
"text/plain",
Expand All @@ -223,7 +230,7 @@
"dvh_track_path": {
"path": "/{clinical_trial}/{test_centre}/Dose Reconstruction/DVH/Patient {centre_patient_no}/",
"display_name": "DVH Track",
"field_type": "file",
"field_type": "folder",
"level": "fraction",
"allowed": [
"text/plain",
Expand All @@ -233,7 +240,7 @@
"dvh_no_track_path": {
"path": "/{clinical_trial}/{test_centre}/Dose Reconstruction/DVH/Patient {centre_patient_no}/",
"display_name": "DVH No Track",
"field_type": "file",
"field_type": "folder",
"level": "fraction",
"allowed": [
"text/plain",
Expand All @@ -243,8 +250,8 @@
"planned_dvh_fraction": {
"path": "/{clinical_trial}/{test_centre}/Dose Reconstruction/DVH/Patient {centre_patient_no}/",
"display_name": "Planned DVH (fraction level)",
"field_type": "file",
"level": "prescription",
"field_type": "folder",
"level": "fraction",
"allowed": [
"text/plain",
"text/csv"
Expand All @@ -253,14 +260,14 @@
"planned_dicom_fraction": {
"path": "/{clinical_trial}/{test_centre}/Dose Reconstruction/DICOM/Patient {centre_patient_no}/",
"display_name": "Planned DICOM (fraction level)",
"field_type": "file",
"field_type": "folder",
"level": "fraction",
"allowed": ["application/dicom"]
},
"dicom_track_plan_path": {
"path": "/{clinical_trial}/{test_centre}/Dose Reconstruction/DICOM/Patient {centre_patient_no}/",
"display_name": "DICOM Track Plan",
"field_type": "file",
"field_type": "folder",
"level": "fraction",
"allowed": [
"application/dicom"
Expand All @@ -272,13 +279,14 @@
"field_type": "folder",
"level": "fraction",
"allowed": [
"application/plain text"
"application/dicom",
"plain/text"
]
},
"dicom_no_track_plan_path": {
"path": "/{clinical_trial}/{test_centre}/Dose Reconstruction/DICOM/Patient {centre_patient_no}/",
"display_name": "DICOM No Track Plan",
"field_type": "file",
"field_type": "folder",
"level": "fraction",
"allowed": [
"application/dicom"
Expand Down
37 changes: 32 additions & 5 deletions src/content_uploader/ContentUploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ def getFileTypes(self) -> Dict:
def updateFileTypes(self, trialFileType) -> None:
self.fileTypes = trialFileType

def getUploadFormatForFileType(self, fileType:str) -> str:
if fileType not in self.fileTypes:
return None
if self.fileTypes[fileType]["field_type"] == "file":
return "File (Please only uplaod one file)"
elif self.fileTypes[fileType]["field_type"] == "folder":
return "Folder (Please drag the entire file folder)"
return self.fileTypes[fileType]["field_type"]

class LoginScreen(QWidget):
authorisationRequested:SignalInstance = Signal()

Expand Down Expand Up @@ -876,6 +885,7 @@ def __init__(self, parent: Optional[QWidget]=None) -> None:
self.cancelRequest = False
self.isPatientIdValidated = False
self.currentProfile = None
self.currentUploadFormatDisplay = None
self._initGUI()

self.loginScreen = LoginScreen()
Expand Down Expand Up @@ -929,8 +939,12 @@ def _initGUI(self):
addTestCentreBtn.setMaximumSize(30, addTestCentreBtn.height())
addTestCentreBtn.clicked.connect(self.showNewTestCentreScreen)

self.fileLevelSelector = QComboBox()
self.fileLevelSelector.addItems(["Prescription", "Fraction"])
self.fileLevelSelector.currentTextChanged.connect(self.changeFileType)

self.fileTypeSelector = QComboBox()
fileTypesItems = self.dbClient.getFileTypesForTrial(self.trialSelector.currentText())
fileTypesItems = self.dbClient.getFileTypesForTrial(self.trialSelector.currentText(), self.fileLevelSelector.currentText())
self.trialsMetaData.updateFileTypes(fileTypesItems)
self.fileTypeSelector.addItems(self.trialsMetaData.getFileTypesSupported())
self.fileTypeSelector.setMaximumWidth(200)
Expand Down Expand Up @@ -968,6 +982,9 @@ def _initGUI(self):

self.patientSequenceInput = QSpinBox()

self.uploadForamtLabel = QLabel()
self.uploadForamtLabel.setText(f"Upload Format: {self.currentUploadFormatDisplay}")

patientIdLayout = QHBoxLayout()
patientIdLayout.addWidget(QLabel("Patient clinical trial ID:"))
patientIdLayout.addWidget(self.patientIdVerifiedIndicator)
Expand Down Expand Up @@ -1000,6 +1017,12 @@ def _initGUI(self):
fileTypeLayout.addWidget(typeofFileLabel)
fileTypeLayout.addWidget(self.fileTypeSelector)

fileLevelLayout = QHBoxLayout()
fileLevelLabel = QLabel("Level:")
fileLevelLabel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
fileLevelLayout.addWidget(fileLevelLabel)
fileLevelLayout.addWidget(self.fileLevelSelector)

mainFractionLayout = QHBoxLayout()
fractionLabel = QLabel("Fraction:")
fractionLabel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)
Expand All @@ -1014,9 +1037,11 @@ def _initGUI(self):
subFractionLayout.addWidget(self.subFractionSelector)
subFractionLayout.addWidget(addSubFractionPushBtn)

inputLayout.addLayout(fileTypeLayout, 0, 0)
inputLayout.addLayout(mainFractionLayout, 1, 0)
inputLayout.addLayout(subFractionLayout, 1, 1)
inputLayout.addLayout(fileLevelLayout, 0, 0)
inputLayout.addLayout(fileTypeLayout, 0, 1)
inputLayout.addWidget(self.uploadForamtLabel, 1, 0, 1, 2)
inputLayout.addLayout(mainFractionLayout, 2, 0)
inputLayout.addLayout(subFractionLayout, 2, 1)
inputLayout.setVerticalSpacing(0)

self.dropArea = DropArea()
Expand Down Expand Up @@ -1516,6 +1541,8 @@ def removeEntryFromUploadTable(self):

@Slot(str)
def fileTypeSelected(self, fileType:str):
self.currentUploadFormatDisplay = self.trialsMetaData.getUploadFormatForFileType(fileType)
self.uploadForamtLabel.setText(f"Upload Format: {self.currentUploadFormatDisplay}")
if self.trialsMetaData.getLevelofFileType(fileType) == "fraction":
self.fractionSelector.setEnabled(True)
else:
Expand All @@ -1527,7 +1554,7 @@ def fileTypeSelected(self, fileType:str):
@Slot(str)
def changeFileType(self):
self.fileTypeSelector.clear()
fileTypes = self.dbClient.getFileTypesForTrial(self.trialSelector.currentText())
fileTypes = self.dbClient.getFileTypesForTrial(self.trialSelector.currentText(), self.fileLevelSelector.currentText())
self.trialsMetaData.updateFileTypes(fileTypes)
self.fileTypeSelector.addItems(self.trialsMetaData.getFileTypesSupported())

Expand Down
6 changes: 4 additions & 2 deletions src/content_uploader/ImagingDBClient/Clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def addSiteAndTrial(self, newDetails:Dict) -> Result:
return Result(success=True, message="Added site and trial successfully")
return Result(success=False, message=f"data service retured {req.status_code}")

def getFileTypesForTrial(self, trialName:str) -> Dict:
def getFileTypesForTrial(self, trialName:str, levelName:str) -> Dict:
if not trialName:
return {}
try:
Expand All @@ -258,5 +258,7 @@ def getFileTypesForTrial(self, trialName:str) -> Dict:
except (Exception, InvalidSchema) as ex:
return {}
if req.status_code == 200:
return req.json()
level = levelName.lower()
if level in req.json():
return req.json()[level]
return {}
23 changes: 13 additions & 10 deletions src/data_service/AccessManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,16 +512,19 @@ def getContentUploaderTrial(trialName:str) ->Dict:
return {}
strucutre = rows[0][0]
result = {}
for key in strucutre.keys():
if strucutre[key]:
displayName = strucutre[key]["display_name"]
contentInfo = {
"level": strucutre[key]["level"],
"key": key,
"field_type": strucutre[key]["field_type"],
"allowed": strucutre[key]["allowed"],
}
result[displayName] = contentInfo
for level in strucutre.keys():
for key in strucutre[level].keys():
if strucutre[level][key]:
displayName = strucutre[level][key]["display_name"]
contentInfo = {
"level": strucutre[level][key]["level"],
"key": key,
"field_type": strucutre[level][key]["field_type"],
"allowed": strucutre[level][key]["allowed"],
}
if level not in result:
result[level] = {}
result[level][displayName] = contentInfo
return result

def addTrialStructure(trialPack:Dict) -> Tuple[bool, str]:
Expand Down

0 comments on commit c87cded

Please sign in to comment.