diff --git a/app/functions/check_version.m b/app/functions/check_version.m deleted file mode 100644 index 63e9cdc..0000000 --- a/app/functions/check_version.m +++ /dev/null @@ -1,89 +0,0 @@ -function result = check_version() -result = ''; -% App check version -% -% -% Authors: -% - Ariosky Areces Gonzalez -% - Deirel Paz Linares -% - Pedro Valdes Sosa - -% - Date: November 15, 2019 -try - if(isnetav()) - % loading local data - local = jsondecode(fileread(strcat('app/properties.json'))); - % finding online data - url = local.generals.url_check; - matlab.net.http.HTTPOptions.VerifyServerName = false; - options = weboptions('ContentType','json','Timeout',Inf,'RequestMethod','auto'); - online = webread(url,options); - disp('-->> Comparing local and master version'); - if(local.generals.version_number < online.generals.version_number) - answer = questdlg({'There a new version available of CiftiStorm pipeline.',' Do you want to update the latest version?'}, ... - 'Update CiftiStorm', ... - 'Yes','No','Close'); - % Handle response - switch answer - case 'Yes' - f = dialog('Position',[300 300 250 80]); - iconsClassName = 'com.mathworks.widgets.BusyAffordance$AffordanceSize'; - iconsSizeEnums = javaMethod('values',iconsClassName); - SIZE_32x32 = iconsSizeEnums(2); % (1) = 16x16, (2) = 32x32 - jObj = com.mathworks.widgets.BusyAffordance(SIZE_32x32, 'Starting update.'); % icon, label - - jObj.setPaintsWhenStopped(true); % default = false - jObj.useWhiteDots(false); % default = false (true is good for dark backgrounds) - javacomponent(jObj.getComponent, [50,10,150,80], f); - jObj.start; - pause(1); - - - %% Download latest version - filename = strcat('CiftiStorm_latest.zip'); - disp(strcat("-->> Downloading laster version.......")); - jObj.setBusyText(strcat("Downloading latest version ")); - - url = local.generals.base_url; - matlab.net.http.HTTPOptions.VerifyServerName = false; - options = weboptions('Timeout',Inf,'RequestMethod','auto'); - downladed_file = websave(filename,url,options); - - %% Unzip lasted version - pause(1); - jObj.setBusyText('Unpacking version...'); - disp(strcat("-->> Unpacking version...")); - - exampleFiles = unzip(filename,pwd); - pause(1); - delete(filename); - - movefile( strcat('CiftiStorm-ESI-master',filesep,'*'), pwd, 'f'); - rmdir CiftiStorm-ESI-master ; - - jObj.stop; - jObj.setBusyText('All done!'); - disp(strcat("-->> All done!")); - pause(2); - delete(f); - - disp('-->> The project is already update with the laster version.'); - disp('-->> The process was stoped to refresh all file'); - disp('-->> Please configure the app properties file, before restart the process.'); - result = 'updated'; - case 'No' - return; - case '' - return; - end - - else - disp('-->> Nothing to update'); - end - end -catch - return; -end -end - - diff --git a/app/functions/init_processing.m b/app/functions/init_processing.m index e5d505c..a37a7f0 100644 --- a/app/functions/init_processing.m +++ b/app/functions/init_processing.m @@ -26,12 +26,48 @@ %% ------------ Checking updates -------------------------- if(app_properties.generals.check_app_update) disp('-->> Checking last project version'); - if(isequal(check_version,'updated')) - return; - end + [updated, errors] = update_version(); + iconnection = isnetav(); + if(iconnection) + % loading local data + local = jsondecode(fileread(strcat('app/properties.json'))); + % finding online data + url = local.generals.url_check; + matlab.net.http.HTTPOptions.VerifyServerName = false; + options = weboptions('ContentType','json','Timeout',Inf,'RequestMethod','auto'); + online = webread(url,options); + disp('-->> Comparing local and master version'); + + if(local.generals.version_number < online.generals.version_number) + answer = questdlg({'There a new version available of CiftiStorm pipeline.',' Do you want to update the latest version?'}, ... + 'Update CiftiStorm', ... + 'Yes','No','Close'); + % Handle response + switch answer + case 'Yes' + [updated, errors] = update_version(); + if(updated) + msg = msgbox({'CiftiStorm was updated with the latest version.',... + 'The application will be closed.'},'Info',"help","modal"); + waitfor(msg); + end + end + else + disp('-->> Nothing to update'); + end + else + disp('-->> Internet connection problems.'); + if(getGlobalGuimode()) + msg = msgbox({'There are some problems with your internet connection.',... + 'Please check your internet conection.'},'Info',"help","modal"); + waitfor(msg); + figure(app.CiftiStormUIFigure); + end + end end - +%% %% ----------- Create CiftiStrom Database --------------------- +%% cfs_create_db() end diff --git a/app/functions/update_version.m b/app/functions/update_version.m new file mode 100644 index 0000000..38181bb --- /dev/null +++ b/app/functions/update_version.m @@ -0,0 +1,63 @@ +function [updated, errors] = update_version() +result = true; +errors = []; +% App check version +% +% +% Authors: +% - Ariosky Areces Gonzalez +% - Deirel Paz Linares +% - Pedro Valdes Sosa + +% - Date: November 15, 2019 +try + %% Download latest version + if(getGlobalGuimode()) + d = uiprogressdlg(app.CiftiStormUIFigure,'Title','Downloading CiftiStorm latest version'); + end + filename = strcat('CiftiStorm_latest.zip'); + disp(strcat("-->> Downloading laster version.......")); + url = local.generals.base_url; + matlab.net.http.HTTPOptions.VerifyServerName = false; + options = weboptions('Timeout',Inf,'RequestMethod','auto'); + downladed_file = websave(filename,url,options); + pause(1); + if(getGlobalGuimode()) + delete(d); + end + + %% Unzip lasted version + if(getGlobalGuimode()) + d = uiprogressdlg(app.CiftiStormUIFigure,'Title','Unziping files'); + end + disp(strcat("-->> Unziping files.......")); + exampleFiles = unzip(filename,pwd); + pause(1); + delete(filename); + if(getGlobalGuimode()) + delete(d); + end + + %% Moving files + if(getGlobalGuimode()) + d = uiprogressdlg(app.CiftiStormUIFigure,'Title','Deploging the new vew version'); + end + disp(strcat("-->> Deploging the new vew version.......")); + movefile( strcat('CiftiStorm-ESI-master',filesep,'*'), pwd, 'f'); + rmdir CiftiStorm-ESI-master ; + + disp('-->> The project is already update with the laster version.'); + disp('-->> The process was stoped to refresh all file'); + disp('-->> Please configure the app properties file, before restart the process.'); + result = 'updated'; + if(getGlobalGuimode()) + delete(d); + end + +catch + updated = false; + return; +end +end + + diff --git a/app/properties.json b/app/properties.json index 6087ae8..004be54 100644 --- a/app/properties.json +++ b/app/properties.json @@ -1 +1 @@ -{ "generals":{ "name":"Automatic Head Model Processing", "version":"v.82", "version_date":"10-15-2024", "version_number":82, "test_data_url":"", "url_check":"https://raw.githubusercontent.com/CCC-members/CiftiStorm-ESI/refs/heads/master/app/properties.json", "base_url":"https://codeload.github.com/CCC-members/CiftiStorm-ESI/zip/master", "check_matlab_version":true, "check_app_update":true }, "matlab_runtime":{ "mac":"http://ssd.mathworks.com/supportfiles/downloads/R2018b/deployment_files/R2018b/installers/maci64/MCR_R2018b_maci64_installer.dmg.zip", "win":"http://ssd.mathworks.com/supportfiles/downloads/R2018b/deployment_files/R2018b/installers/win64/MCR_R2018b_win64_installer.exe", "linux":"http://ssd.mathworks.com/supportfiles/downloads/R2018b/deployment_files/R2018b/installers/glnxa64/MCR_R2018b_glnxa64_installer.zip" }, "process_files":[ { "description":"Define StP_general_params. you can change the file and save different conbinations.", "module_id":"general_params", "file_path":"cfs_properties/general_params.json" }, { "description":"Define StP_general_params. you can change the file and save different conbinations.", "module_id":"anatomy_params", "file_path":"cfs_properties/process_import_anat.json" }, { "description":"Define StP_import_channel. you can change the file and save different conbinations.", "module_id":"channel_params", "file_path":"cfs_properties/process_import_channel.json" }, { "description":"Define StP_comp_headmodel. you can change the file and save different conbinations.", "module_id":"headmodel_params", "file_path":"cfs_properties/process_comp_headmodel.json" }, { "description":"Define StP_integration. you can change the file and save different conbinations.", "module_id":"integration_params", "file_path":"cfs_properties/process_integration.json" } ], "default_param_files":[ { "description":"Define StP_general_params. you can change the file and save different conbinations.", "module_id":"general_params", "file_path":"cfs_properties/defaults/general_params.json" }, { "description":"Define StP_general_params. you can change the file and save different conbinations.", "module_id":"anatomy_params", "file_path":"cfs_properties/defaults/process_import_anat.json" }, { "description":"Define StP_import_channel. you can change the file and save different conbinations.", "module_id":"channel_params", "file_path":"cfs_properties/defaults/process_import_channel.json" }, { "description":"Define StP_comp_headmodel. you can change the file and save different conbinations.", "module_id":"headmodel_params", "file_path":"cfs_properties/defaults/process_comp_headmodel.json" }, { "description":"Define StP_integration. you can change the file and save different conbinations.", "module_id":"integration_params", "file_path":"cfs_properties/defaults/process_integration.json" } ] } \ No newline at end of file +{ "generals":{ "name":"Automatic Head Model Processing", "version":"v.83", "version_date":"10-16-2024", "version_number":83, "test_data_url":"", "url_check":"https://raw.githubusercontent.com/CCC-members/CiftiStorm-ESI/refs/heads/master/app/properties.json", "base_url":"https://codeload.github.com/CCC-members/CiftiStorm-ESI/zip/master", "check_matlab_version":true, "check_app_update":true }, "matlab_runtime":{ "mac":"http://ssd.mathworks.com/supportfiles/downloads/R2018b/deployment_files/R2018b/installers/maci64/MCR_R2018b_maci64_installer.dmg.zip", "win":"http://ssd.mathworks.com/supportfiles/downloads/R2018b/deployment_files/R2018b/installers/win64/MCR_R2018b_win64_installer.exe", "linux":"http://ssd.mathworks.com/supportfiles/downloads/R2018b/deployment_files/R2018b/installers/glnxa64/MCR_R2018b_glnxa64_installer.zip" }, "process_files":[ { "description":"Define StP_general_params. you can change the file and save different conbinations.", "module_id":"general_params", "file_path":"cfs_properties/general_params.json" }, { "description":"Define StP_general_params. you can change the file and save different conbinations.", "module_id":"anatomy_params", "file_path":"cfs_properties/process_import_anat.json" }, { "description":"Define StP_import_channel. you can change the file and save different conbinations.", "module_id":"channel_params", "file_path":"cfs_properties/process_import_channel.json" }, { "description":"Define StP_comp_headmodel. you can change the file and save different conbinations.", "module_id":"headmodel_params", "file_path":"cfs_properties/process_comp_headmodel.json" }, { "description":"Define StP_integration. you can change the file and save different conbinations.", "module_id":"integration_params", "file_path":"cfs_properties/process_integration.json" } ], "default_param_files":[ { "description":"Define StP_general_params. you can change the file and save different conbinations.", "module_id":"general_params", "file_path":"cfs_properties/defaults/general_params.json" }, { "description":"Define StP_general_params. you can change the file and save different conbinations.", "module_id":"anatomy_params", "file_path":"cfs_properties/defaults/process_import_anat.json" }, { "description":"Define StP_import_channel. you can change the file and save different conbinations.", "module_id":"channel_params", "file_path":"cfs_properties/defaults/process_import_channel.json" }, { "description":"Define StP_comp_headmodel. you can change the file and save different conbinations.", "module_id":"headmodel_params", "file_path":"cfs_properties/defaults/process_comp_headmodel.json" }, { "description":"Define StP_integration. you can change the file and save different conbinations.", "module_id":"integration_params", "file_path":"cfs_properties/defaults/process_integration.json" } ] } \ No newline at end of file diff --git a/guide/CiftiStorm.mlapp b/guide/CiftiStorm.mlapp index 1af9913..c615881 100755 Binary files a/guide/CiftiStorm.mlapp and b/guide/CiftiStorm.mlapp differ