From c94871a1f57fdd26b7f092ded2df92a73f8616e8 Mon Sep 17 00:00:00 2001 From: Sophie Thorpe Date: Wed, 27 Mar 2024 12:42:17 -0500 Subject: [PATCH 1/6] import routes changed --- .../server/routes/import_routes.py | 62 +++++++++++++------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/minerva_analysis/server/routes/import_routes.py b/minerva_analysis/server/routes/import_routes.py index c8216ee79..56c48c70b 100644 --- a/minerva_analysis/server/routes/import_routes.py +++ b/minerva_analysis/server/routes/import_routes.py @@ -211,26 +211,50 @@ def upload_file_page(): if request.form.get('mcmicro_name') != '': datasetName = request.form['mcmicro_name'] - # get label file from user specified path - labelName = request.form['masks'] - labelFolder = str(PurePath('unmicst-' + mcmicroDirName, labelName + '.ome.tif')) - labelFile = PurePath(directory, 'segmentation', labelFolder) - - # also check for older seg file format (.tif) - if not Path(directory, 'segmentation', labelFolder).is_file(): - labelFolder = str(PurePath('unmicst-' + mcmicroDirName, labelName + '.tif')) - labelFile = PurePath(directory, 'segmentation', labelFolder) - - # get csv file from user specified path - csvName = mcmicroDirName + '--unmicst_' + labelName + '.csv' # could use labelName to have dynamic csv but usually only cell available. - csvPath = str(PurePath(directory, 'quantification', csvName)) - - # get channel file from user specified path - channelFile = PurePath(directory, 'registration', mcmicroDirName + '.ome.tif') - - #further processing + # Given directory, look for all files ending in ome.tif, ome.tiff, .tif, or .tiff + imageFileNames = [] + imageFilePaths = [] + for path in Path(directory).rglob('*.ome.tif|*ome.tiff|*.tif|*.tiff'): + imageFileNames.append(path.name) + imageFilePaths.append(path) + + # This is just to test if the new logic is working; need to go back + # and connect this to a dropdown menu later + labelFile = imageFilePaths[0] + channelFile = imageFilePaths[1] + + csvFileNames= [] + csvFilePaths = [] + # Given directory, look for all files ending in .csv + for path in Path(directory).rglob('*.csv'): + csvFileNames.append(path.name) + csvFilePaths.append(path) + + # This is just to test if the new logic is working; need to go back + # and connect this to a dropdown menu later + csvName = csvFileNames[0] + csvPath = csvFilePaths[0] + + # # get label file from user specified path + # labelName = request.form['masks'] + # labelFolder = str(PurePath('unmicst-' + mcmicroDirName, labelName + '.ome.tif')) + # labelFile = PurePath(directory, 'segmentation', labelFolder) + + # # also check for older seg file format (.tif) + # if not Path(directory, 'segmentation', labelFolder).is_file(): + # labelFolder = str(PurePath('unmicst-' + mcmicroDirName, labelName + '.tif')) + # labelFile = PurePath(directory, 'segmentation', labelFolder) + + # # get csv file from user specified path + # csvName = mcmicroDirName + '--unmicst_' + labelName + '.csv' # could use labelName to have dynamic csv but usually only cell available. + # csvPath = str(PurePath(directory, 'quantification', csvName)) + + # # get channel file from user specified path + # channelFile = PurePath(directory, 'registration', mcmicroDirName + '.ome.tif') + + # Creates file path using name input; should change this so that it just takes directory name? file_path = str(PurePath(Path.cwd(), data_path, datasetName)) - if not Path(file_path).exists(): + if not Path(file_path).exists(): # If no directory for existing name for dataset input will create one Path(file_path).mkdir() total_tasks = 2 From 3aa1997aa037e5a30f6231c75fd78ccdb8a211aa Mon Sep 17 00:00:00 2001 From: Sophie Thorpe Date: Wed, 10 Apr 2024 12:37:02 -0500 Subject: [PATCH 2/6] new upload form --- .../src/js/services/importFormValidation.js | 95 +++++++++++- minerva_analysis/client/templates/upload.html | 30 +++- .../server/routes/import_routes.py | 135 ++++++++++++------ 3 files changed, 214 insertions(+), 46 deletions(-) diff --git a/minerva_analysis/client/src/js/services/importFormValidation.js b/minerva_analysis/client/src/js/services/importFormValidation.js index 65709f51e..70aab404c 100644 --- a/minerva_analysis/client/src/js/services/importFormValidation.js +++ b/minerva_analysis/client/src/js/services/importFormValidation.js @@ -98,6 +98,9 @@ async function checkChannelExistence(caller) { let pathInputField = d3.select('#'+ caller.id); let path = pathInputField.property("value"); + let imageSelectionField = d3.select('#'+ caller.id); + let image = imageSelectionField.property("value"); + try { //check if corresponsindg csv file exists let response = await fetch('/check_mc_channel_file_existence', { @@ -109,6 +112,7 @@ async function checkChannelExistence(caller) { body: JSON.stringify( { path: path, + image : image } ) }); @@ -239,7 +243,7 @@ try { } //get a list of available files in a folder (mcmicro naming specific) -async function fillSegFileList() { +async function fillCSVFileList() { const self = this; //get segmentation folder path from the input text field @@ -251,6 +255,50 @@ async function fillSegFileList() { select_field.remove(0); } + try { + //get available segmentation masks in mcmicro directory from server + let response = await fetch('/get_mc_csv_file_list', { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify( + { + path: path, + } + ) + }); + let response_data = await response.json(); + + //fill select form field with new options + response_data.forEach(function(option_value){ + var option = document.createElement("option"); + option.text = option_value; + option.value = option_value; + select_field.add(option); + }) + + //return the filled field + return response_data; + } catch (e) { + console.log("Error Getting Segmentation File List", e); + } +} + +//get a list of available files in a folder (mcmicro naming specific) +async function fillImgFileList() { + const self = this; + + //get segmentation folder path from the input text field + let path = d3.select('#mcmicro_output_folder').property("value"); + + //remove old selection options as soon as path changes + var select_field = document.getElementById("mcmicro_images"); + while (select_field.length > 0) { + select_field.remove(0); + } + try { //get available segmentation masks in mcmicro directory from server let response = await fetch('/get_mc_segmentation_file_list', { @@ -274,7 +322,51 @@ async function fillSegFileList() { option.value = option_value; select_field.add(option); }) + + //return the filled field + return response_data; + } catch (e) { + console.log("Error Getting Channel File List", e); + } +} +//get a list of available files in a folder (mcmicro naming specific) +async function fillSegFileList() { + const self = this; + + //get segmentation folder path from the input text field + let path = d3.select('#mcmicro_output_folder').property("value"); + + //remove old selection options as soon as path changes + var select_field = document.getElementById("mcmicro_seg"); + while (select_field.length > 0) { + select_field.remove(0); + } + + try { + //get available segmentation masks in mcmicro directory from server + let response = await fetch('/get_mc_segmentation_file_list', { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify( + { + path: path, + } + ) + }); + let response_data = await response.json(); + + //fill select form field with new options + response_data.forEach(function(option_value){ + var option = document.createElement("option"); + option.text = option_value; + option.value = option_value; + select_field.add(option); + }) + //return the filled field return response_data; } catch (e) { @@ -282,6 +374,7 @@ async function fillSegFileList() { } } + let uploadPercentage = 0; let ajaxForm = $('form').ajaxForm({ uploadProgress: function (event, position, total, percentComplete) { diff --git a/minerva_analysis/client/templates/upload.html b/minerva_analysis/client/templates/upload.html index d745b872d..8a21464f7 100644 --- a/minerva_analysis/client/templates/upload.html +++ b/minerva_analysis/client/templates/upload.html @@ -96,7 +96,7 @@
- +
Valid.
Please provide a valid path. @@ -106,7 +106,7 @@
- +
+ +
Valid.
+
+ No image files found under this path. +
+
+
+
+
+ +
+
+ +
Valid.
+
+ No image files found under this path. +
+
+
diff --git a/minerva_analysis/server/routes/import_routes.py b/minerva_analysis/server/routes/import_routes.py index 56c48c70b..2f05bbe54 100644 --- a/minerva_analysis/server/routes/import_routes.py +++ b/minerva_analysis/server/routes/import_routes.py @@ -1,5 +1,7 @@ # CRUD for Datasources +# import sys +# sys.path.append('/c/Users/Sophie/minerva_analysis/') from minerva_analysis import app, get_config_names, config_json_path, data_path, cwd_path from minerva_analysis.server.utils import mostFrequentLongestSubstring, pre_normalization from minerva_analysis.server.models import data_model @@ -19,6 +21,7 @@ from os import walk import io + total_tasks = 100 completed_task = 0 current_task = '' @@ -211,29 +214,24 @@ def upload_file_page(): if request.form.get('mcmicro_name') != '': datasetName = request.form['mcmicro_name'] - # Given directory, look for all files ending in ome.tif, ome.tiff, .tif, or .tiff - imageFileNames = [] - imageFilePaths = [] - for path in Path(directory).rglob('*.ome.tif|*ome.tiff|*.tif|*.tiff'): - imageFileNames.append(path.name) - imageFilePaths.append(path) - - # This is just to test if the new logic is working; need to go back - # and connect this to a dropdown menu later - labelFile = imageFilePaths[0] - channelFile = imageFilePaths[1] - - csvFileNames= [] - csvFilePaths = [] - # Given directory, look for all files ending in .csv - for path in Path(directory).rglob('*.csv'): - csvFileNames.append(path.name) - csvFilePaths.append(path) - - # This is just to test if the new logic is working; need to go back - # and connect this to a dropdown menu later - csvName = csvFileNames[0] - csvPath = csvFilePaths[0] + #label file + labelFile = request.form.get('segs') + labelFile = labelFile.replace('"', '') # remove " characters + labelFile = Path(labelFile) + labelName = os.path.splitext(labelFile.name)[0] + + #csv file + csvPath = request.form.get('masks'); + csvPath = csvPath.replace('"', '') # remove " characters + csvPath = Path(csvPath) + pathsSplit = PurePath(csvPath).parts + csvName = pathsSplit[len(pathsSplit) - 1] + + #channel file + channelFile = request.form.get('images') + channelFile = channelFile.replace('"', '') # remove " characters + channelFile = Path(channelFile) + # # get label file from user specified path # labelName = request.form['masks'] @@ -534,22 +532,55 @@ def list_tif_files_in_dir(): #path and type information from upload post_data = json.loads(request.data) if 'path' in post_data: - path = Path(post_data['path'], "segmentation"); + # path = Path(post_data['path'], "segmentation"); + path = Path(post_data['path']) #for segmentation, mcmicro specifics - mask_types = ["cell", "cellRing", "cyto", "cytoRing", "nuclei", "nucleiRing"] + # mask_types = ["cell", "cellRing", "cyto", "cytoRing", "nuclei", "nucleiRing"] if path.is_dir(): for (dirpath, dirnames, filenames) in walk(path): for (file) in filenames: - file = file.split('.') - if file[0] in mask_types: - files.append(file[0]) + file_split = file.split('.') + # if file[0] in mask_types: + # files.append(file[0]) + if (file_split[-1] == 'tif' and file_split[-2] == 'ome') or (file_split[-1] == 'tiff' and file_split[-2] == 'ome'): + file_path = os.path.join(dirpath, file) + files.append(file_path) print(files) else: print('error in segmentation path'); return serialize_and_submit_json(files) +@app.route('/get_mc_csv_file_list', methods=['POST']) +def list_csv_files_in_dir(): + # return all seg files found in the seg subfolder (mc micro specific) + files = [] + files.append('') + + #path and type information from upload + post_data = json.loads(request.data) + if 'path' in post_data: + # path = Path(post_data['path'], "segmentation"); + path = Path(post_data['path']) + + #for segmentation, mcmicro specifics + # mask_types = ["cell", "cellRing", "cyto", "cytoRing", "nuclei", "nucleiRing"] + + if path.is_dir(): + for (dirpath, dirnames, filenames) in walk(path): + for (file) in filenames: + file_split = file.split('.') + # if file[0] in mask_types: + # files.append(file[0]) + if file_split[-1] == 'csv': + file_path = os.path.join(dirpath, file) + files.append(file_path) + print(files) + else: + print('error in csv path'); + return serialize_and_submit_json(files) + @app.route('/check_mc_csv_file_existence', methods=['POST']) def check_mc_csv_file_existence(): # path and type information from upload @@ -564,11 +595,23 @@ def check_mc_csv_file_existence(): # check if csv file exists # csvName = 'nmicst-' + mcmicroDirName + '_' + mask + '.csv' - csvName = mcmicroDirName + '--unmicst_' + mask + '.csv' - csvPath = Path(directory, 'quantification', csvName) + # csvName = mcmicroDirName + '--unmicst_' + mask + '.csv' + # csvPath = Path(directory, 'quantification', csvName) + + # if csvPath.is_file(): + # return serialize_and_submit_json(True) + + # # Get suffix of file path + # file_extension = directory.suffix - if csvPath.is_file(): + # # Check if file extension is ".csv" + # if file_extension.lower() == '.csv': + # return serialize_and_submit_json(True) + + path = Path(post_data['mask']) + if path.suffix.lower() == '.csv': return serialize_and_submit_json(True) + return serialize_and_submit_json(False) @app.route('/check_mc_channel_file_existence', methods=['POST']) @@ -576,19 +619,25 @@ def check_mc_channel_file_existence(): # path and type information from upload post_data = json.loads(request.data) if 'path' in post_data: - #get path and last bit which defines the dirname - directory = Path(post_data['path']) - try: - pathsSplit = PurePath(directory).parts - mcmicroDirName = pathsSplit[len(pathsSplit) - 1] - - # check if channel file exists - channelFile = Path(directory, 'registration', mcmicroDirName + '.ome.tif') or Path(directory, 'registration', mcmicroDirName + '.ome.tiff') + # #get path and last bit which defines the dirname + # directory = Path(post_data['path']) + # try: + # pathsSplit = PurePath(directory).parts + # mcmicroDirName = pathsSplit[len(pathsSplit) - 1] + + # # check if channel file exists + # channelFile = Path(directory, 'registration', mcmicroDirName + '.ome.tif') or Path(directory, 'registration', mcmicroDirName + '.ome.tiff') + + # if channelFile.is_file(): + # return serialize_and_submit_json(True) + # except Exception as e: + # return serialize_and_submit_json(False) + + if 'image' in post_data: + path = Path(post_data['image']) + if path.suffix.lower() == '.tif' or '.tiff': + return serialize_and_submit_json(True) - if channelFile.is_file(): - return serialize_and_submit_json(True) - except Exception as e: - return serialize_and_submit_json(False) return serialize_and_submit_json(False) @app.route('/check_file_existence', methods=['POST']) From ea3c8e0c27e37a5d89d7de3e955684ea9432e674 Mon Sep 17 00:00:00 2001 From: Simon Warchol Date: Wed, 10 Apr 2024 13:49:14 -0400 Subject: [PATCH 3/6] Adding form validation stuff --- .../src/js/services/importFormValidation.js | 133 +++++++++--------- 1 file changed, 65 insertions(+), 68 deletions(-) diff --git a/minerva_analysis/client/src/js/services/importFormValidation.js b/minerva_analysis/client/src/js/services/importFormValidation.js index 70aab404c..47b886956 100644 --- a/minerva_analysis/client/src/js/services/importFormValidation.js +++ b/minerva_analysis/client/src/js/services/importFormValidation.js @@ -2,30 +2,30 @@ // Example starter JavaScript for disabling form submissions if there are invalid fields (function () { - 'use strict' - - // Fetch all the forms we want to apply custom Bootstrap validation styles to - var forms = document.querySelectorAll('.needs-validation') - // Loop over them and prevent submission - Array.prototype.slice.call(forms) - .forEach(function (form) { - form.addEventListener('submit', function (event) { - if (!form.checkValidity()) { - event.preventDefault() - event.stopPropagation() - }else{ - onupload(); - } - form.classList.add('was-validated') - }, true) - }) + 'use strict' + + // Fetch all the forms we want to apply custom Bootstrap validation styles to + var forms = document.querySelectorAll('.needs-validation') + // Loop over them and prevent submission + Array.prototype.slice.call(forms) + .forEach(function (form) { + form.addEventListener('submit', function (event) { + if (!form.checkValidity()) { + event.preventDefault() + event.stopPropagation() + } else { + onupload(); + } + form.classList.add('was-validated') + }, true) + }) })() //add listener -d3.select("#import_type").on("change",update); +d3.select("#import_type").on("change", update); -function update(){ - if(d3.select("#import_type").property("checked")){ +function update() { + if (d3.select("#import_type").property("checked")) { console.log('is checked'); d3.select('#mcmicro_form').style("display", 'inline'); d3.select('#custom_form').style("display", 'none'); @@ -36,15 +36,15 @@ function update(){ } //check if path and channel file exist in the specified MCMICRO output foder -async function checkMCOutputFolder(caller){ +async function checkMCOutputFolder(caller) { let path_res = await checkPathExistence(caller); - if (path_res == true){ + if (path_res == true) { let channel_res = await checkChannelExistence(caller) - if (channel_res == false){ - d3.select("#" + 'mcmicro_path_validation_text').html('No image channel file found under this path.') - } - }else{ - d3.select("#" + 'mcmicro_path_validation_text').html('Please provide a valid path.') + if (channel_res == false) { + d3.select("#" + 'mcmicro_path_validation_text').html('No image channel file found under this path.') + } + } else { + d3.select("#" + 'mcmicro_path_validation_text').html('Please provide a valid path.') } } @@ -53,11 +53,11 @@ async function checkCSVFileExistence(caller) { const self = this; //get folder path from the input text field - let maskSelectionField = d3.select('#'+ caller.id); + let maskSelectionField = d3.select('#' + caller.id); let mask = maskSelectionField.property("value"); //get selected mask type from the selection field - let pathInputField = d3.select('#'+ 'mcmicro_output_folder'); + let pathInputField = d3.select('#' + 'mcmicro_output_folder'); let path = pathInputField.property("value"); try { @@ -71,15 +71,15 @@ async function checkCSVFileExistence(caller) { body: JSON.stringify( { path: path, - mask : mask + mask: mask } ) }); let response_data = await response.json(); - if (response_data == true){ + if (response_data == true) { maskSelectionField.attr("class", "form-control is-valid"); maskSelectionField.node().setCustomValidity(''); - }else{ + } else { d3.select("#" + 'mcmicro_mask_validation_text').html('No corresponding csv file found.') maskSelectionField.attr("class", "form-control is-invalid"); maskSelectionField.node().setCustomValidity('Invalid'); @@ -95,10 +95,10 @@ async function checkChannelExistence(caller) { const self = this; //get folder path from the input text field - let pathInputField = d3.select('#'+ caller.id); + let pathInputField = d3.select('#' + caller.id); let path = pathInputField.property("value"); - let imageSelectionField = d3.select('#'+ caller.id); + let imageSelectionField = d3.select('#' + caller.id); let image = imageSelectionField.property("value"); try { @@ -112,15 +112,15 @@ async function checkChannelExistence(caller) { body: JSON.stringify( { path: path, - image : image + image: image } ) }); let response_data = await response.json(); - if (response_data == true){ + if (response_data == true) { pathInputField.attr("class", "form-control is-valid"); pathInputField.node().setCustomValidity(''); - }else{ + } else { // d3.select("#" + 'mcmicro_path_validation_text').html('No image channel file found under this path.') pathInputField.attr("class", "form-control is-invalid"); pathInputField.node().setCustomValidity('No image channel file found under this path.'); @@ -136,11 +136,11 @@ async function checkChannelExistence(caller) { //check if path exists (mcmicro naming specific) async function checkFileExistence(caller) { const self = this; - let inputField = d3.select('#'+ caller.id); + let inputField = d3.select('#' + caller.id); //get segmentation folder path from the input text field let path = inputField.property("value"); -try { + try { //get available segmentation masks in mcmicro directory from server let response = await fetch('/check_file_existence', { method: 'POST', @@ -155,12 +155,12 @@ try { ) }); let response_data = await response.json(); - if (response_data == true){ + if (response_data == true) { inputField.attr("class", "form-control is-valid"); inputField.node().setCustomValidity(''); - }else{ - inputField.attr("class", "form-control is-invalid"); - inputField.node().setCustomValidity('Invalid'); + } else { + inputField.attr("class", "form-control is-invalid"); + inputField.node().setCustomValidity('Invalid'); } return response_data; } catch (e) { @@ -173,11 +173,11 @@ try { //check if path exists (mcmicro naming specific) async function checkDatasetExistence(caller) { const self = this; - let inputField = d3.select('#'+ caller.id); + let inputField = d3.select('#' + caller.id); //get segmentation folder path from the input text field let datasetName = inputField.property("value"); -try { + try { //get available segmentation masks in mcmicro directory from server let response = await fetch('/dataset_existence', { method: 'POST', @@ -192,12 +192,12 @@ try { ) }); let response_data = await response.json(); - if (response_data == false){ + if (response_data == false) { inputField.attr("class", "form-control is-valid"); inputField.node().setCustomValidity(''); - }else{ - inputField.attr("class", "form-control is-invalid"); - inputField.node().setCustomValidity('Dataset name already exists. Choose a different name.'); + } else { + inputField.attr("class", "form-control is-invalid"); + inputField.node().setCustomValidity('Dataset name already exists. Choose a different name.'); } // inputField.node().reportValidity(); return response_data; @@ -209,11 +209,11 @@ try { //check if path exists (mcmicro naming specific) async function checkPathExistence(caller) { const self = this; - let inputField = d3.select('#'+ caller.id); + let inputField = d3.select('#' + caller.id); //get segmentation folder path from the input text field let path = inputField.property("value"); -try { + try { //get available segmentation masks in mcmicro directory from server let response = await fetch('/check_path_existence', { method: 'POST', @@ -228,12 +228,12 @@ try { ) }); let response_data = await response.json(); - if (response_data == true){ + if (response_data == true) { inputField.attr("class", "form-control is-valid"); inputField.node().setCustomValidity(''); - }else{ - inputField.attr("class", "form-control is-invalid"); - inputField.node().setCustomValidity('Path does not exist.'); + } else { + inputField.attr("class", "form-control is-invalid"); + inputField.node().setCustomValidity('Path does not exist.'); } // inputField.node().reportValidity(); return response_data; @@ -251,9 +251,7 @@ async function fillCSVFileList() { //remove old selection options as soon as path changes var select_field = document.getElementById("mcmicro_masks"); - while (select_field.length > 0) { - select_field.remove(0); - } + select_field.innerHTML = ""; try { //get available segmentation masks in mcmicro directory from server @@ -272,13 +270,13 @@ async function fillCSVFileList() { let response_data = await response.json(); //fill select form field with new options - response_data.forEach(function(option_value){ + response_data.forEach(function (option_value) { var option = document.createElement("option"); option.text = option_value; option.value = option_value; select_field.add(option); }) - + //return the filled field return response_data; } catch (e) { @@ -293,11 +291,10 @@ async function fillImgFileList() { //get segmentation folder path from the input text field let path = d3.select('#mcmicro_output_folder').property("value"); + //remove old selection options as soon as path changes var select_field = document.getElementById("mcmicro_images"); - while (select_field.length > 0) { - select_field.remove(0); - } + select_field.innerHTML = ""; try { //get available segmentation masks in mcmicro directory from server @@ -316,13 +313,13 @@ async function fillImgFileList() { let response_data = await response.json(); //fill select form field with new options - response_data.forEach(function(option_value){ + response_data.forEach(function (option_value) { var option = document.createElement("option"); option.text = option_value; option.value = option_value; select_field.add(option); }) - + //return the filled field return response_data; } catch (e) { @@ -340,7 +337,7 @@ async function fillSegFileList() { //remove old selection options as soon as path changes var select_field = document.getElementById("mcmicro_seg"); while (select_field.length > 0) { - select_field.remove(0); + select_field.remove(0); } try { @@ -360,13 +357,13 @@ async function fillSegFileList() { let response_data = await response.json(); //fill select form field with new options - response_data.forEach(function(option_value){ + response_data.forEach(function (option_value) { var option = document.createElement("option"); option.text = option_value; option.value = option_value; select_field.add(option); }) - + //return the filled field return response_data; } catch (e) { From ecd443e55edfe32e2093f3ae5313bc8c8fcad3aa Mon Sep 17 00:00:00 2001 From: Sophie Thorpe Date: Wed, 10 Apr 2024 12:54:45 -0500 Subject: [PATCH 4/6] got rid of excess code --- .../server/routes/import_routes.py | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/minerva_analysis/server/routes/import_routes.py b/minerva_analysis/server/routes/import_routes.py index 2f05bbe54..ad2c4d23b 100644 --- a/minerva_analysis/server/routes/import_routes.py +++ b/minerva_analysis/server/routes/import_routes.py @@ -232,24 +232,6 @@ def upload_file_page(): channelFile = channelFile.replace('"', '') # remove " characters channelFile = Path(channelFile) - - # # get label file from user specified path - # labelName = request.form['masks'] - # labelFolder = str(PurePath('unmicst-' + mcmicroDirName, labelName + '.ome.tif')) - # labelFile = PurePath(directory, 'segmentation', labelFolder) - - # # also check for older seg file format (.tif) - # if not Path(directory, 'segmentation', labelFolder).is_file(): - # labelFolder = str(PurePath('unmicst-' + mcmicroDirName, labelName + '.tif')) - # labelFile = PurePath(directory, 'segmentation', labelFolder) - - # # get csv file from user specified path - # csvName = mcmicroDirName + '--unmicst_' + labelName + '.csv' # could use labelName to have dynamic csv but usually only cell available. - # csvPath = str(PurePath(directory, 'quantification', csvName)) - - # # get channel file from user specified path - # channelFile = PurePath(directory, 'registration', mcmicroDirName + '.ome.tif') - # Creates file path using name input; should change this so that it just takes directory name? file_path = str(PurePath(Path.cwd(), data_path, datasetName)) if not Path(file_path).exists(): # If no directory for existing name for dataset input will create one @@ -592,21 +574,6 @@ def check_mc_csv_file_existence(): directory = Path(post_data['path']) pathsSplit = PurePath(directory).parts mcmicroDirName = pathsSplit[len(pathsSplit) - 1] - - # check if csv file exists - # csvName = 'nmicst-' + mcmicroDirName + '_' + mask + '.csv' - # csvName = mcmicroDirName + '--unmicst_' + mask + '.csv' - # csvPath = Path(directory, 'quantification', csvName) - - # if csvPath.is_file(): - # return serialize_and_submit_json(True) - - # # Get suffix of file path - # file_extension = directory.suffix - - # # Check if file extension is ".csv" - # if file_extension.lower() == '.csv': - # return serialize_and_submit_json(True) path = Path(post_data['mask']) if path.suffix.lower() == '.csv': @@ -619,19 +586,6 @@ def check_mc_channel_file_existence(): # path and type information from upload post_data = json.loads(request.data) if 'path' in post_data: - # #get path and last bit which defines the dirname - # directory = Path(post_data['path']) - # try: - # pathsSplit = PurePath(directory).parts - # mcmicroDirName = pathsSplit[len(pathsSplit) - 1] - - # # check if channel file exists - # channelFile = Path(directory, 'registration', mcmicroDirName + '.ome.tif') or Path(directory, 'registration', mcmicroDirName + '.ome.tiff') - - # if channelFile.is_file(): - # return serialize_and_submit_json(True) - # except Exception as e: - # return serialize_and_submit_json(False) if 'image' in post_data: path = Path(post_data['image']) From 997a075d1a0c0e981b9a57ab78eef15b262db52f Mon Sep 17 00:00:00 2001 From: Sophie Thorpe Date: Wed, 10 Apr 2024 12:59:28 -0500 Subject: [PATCH 5/6] seg file dropdown population fixed --- .../client/src/js/services/importFormValidation.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/minerva_analysis/client/src/js/services/importFormValidation.js b/minerva_analysis/client/src/js/services/importFormValidation.js index 47b886956..90e943b9c 100644 --- a/minerva_analysis/client/src/js/services/importFormValidation.js +++ b/minerva_analysis/client/src/js/services/importFormValidation.js @@ -336,9 +336,7 @@ async function fillSegFileList() { //remove old selection options as soon as path changes var select_field = document.getElementById("mcmicro_seg"); - while (select_field.length > 0) { - select_field.remove(0); - } + select_field.innerHTML = ""; try { //get available segmentation masks in mcmicro directory from server From 9324e6860d2d79873148c70dd5f26e0eab5016cf Mon Sep 17 00:00:00 2001 From: Simon Warchol Date: Wed, 10 Apr 2024 14:04:30 -0400 Subject: [PATCH 6/6] trying one thing --- .../src/js/services/importFormValidation.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/minerva_analysis/client/src/js/services/importFormValidation.js b/minerva_analysis/client/src/js/services/importFormValidation.js index 90e943b9c..44dd04c6f 100644 --- a/minerva_analysis/client/src/js/services/importFormValidation.js +++ b/minerva_analysis/client/src/js/services/importFormValidation.js @@ -250,8 +250,7 @@ async function fillCSVFileList() { let path = d3.select('#mcmicro_output_folder').property("value"); //remove old selection options as soon as path changes - var select_field = document.getElementById("mcmicro_masks"); - select_field.innerHTML = ""; + try { //get available segmentation masks in mcmicro directory from server @@ -268,7 +267,8 @@ async function fillCSVFileList() { ) }); let response_data = await response.json(); - + var select_field = document.getElementById("mcmicro_masks"); + select_field.innerHTML = ""; //fill select form field with new options response_data.forEach(function (option_value) { var option = document.createElement("option"); @@ -292,9 +292,7 @@ async function fillImgFileList() { let path = d3.select('#mcmicro_output_folder').property("value"); - //remove old selection options as soon as path changes - var select_field = document.getElementById("mcmicro_images"); - select_field.innerHTML = ""; + try { //get available segmentation masks in mcmicro directory from server @@ -311,7 +309,9 @@ async function fillImgFileList() { ) }); let response_data = await response.json(); - + //remove old selection options as soon as path changes + var select_field = document.getElementById("mcmicro_images"); + select_field.innerHTML = ""; //fill select form field with new options response_data.forEach(function (option_value) { var option = document.createElement("option"); @@ -335,8 +335,7 @@ async function fillSegFileList() { let path = d3.select('#mcmicro_output_folder').property("value"); //remove old selection options as soon as path changes - var select_field = document.getElementById("mcmicro_seg"); - select_field.innerHTML = ""; + try { //get available segmentation masks in mcmicro directory from server @@ -353,7 +352,8 @@ async function fillSegFileList() { ) }); let response_data = await response.json(); - + var select_field = document.getElementById("mcmicro_seg"); + select_field.innerHTML = ""; //fill select form field with new options response_data.forEach(function (option_value) { var option = document.createElement("option");