├── .gitignore ├── LICENSE ├── README.md ├── TREX Icon.png ├── TREX Title.png ├── TREX.fig ├── TREX.m ├── Thumbs.db ├── config.trex ├── credits.trex ├── dose ├── Dose Parameter Profiles │ ├── parameters_default.trex │ ├── parameters_default_and_subsetmaps.trex │ ├── parameters_default_and_texturemaps.trex │ └── parameters_texturemaps_only.trex ├── doseX.fig ├── doseX.m ├── dose_modules │ ├── dfh_features.m │ ├── dose_dvh │ │ ├── dvh_doseX.m │ │ └── dvh_features.m │ ├── dose_location │ │ ├── location_doseX.m │ │ └── location_features.m │ ├── dose_mapdvh │ │ ├── defunct_mapdvh_features.m │ │ ├── mapdvh_doseX.m │ │ └── mapdvh_features.m │ ├── dose_plan │ │ ├── plan_doseX.m │ │ └── plan_features.m │ └── dose_spatialdvh │ │ ├── spatialdvh_doseX.m │ │ ├── spatialdvh_features.m │ │ └── spatialdvh_weight.m ├── dose_parameters │ ├── parameterfields_doseX.m │ ├── parameters_doseX.m │ ├── profileread_doseX.m │ └── profilewrite_doseX.m ├── read_doseX.m ├── remove_doseX.m ├── start_doseX.m ├── startmodule_doseX.m └── write_doseX.m ├── extract ├── extractX.fig ├── extractX.m ├── pinnacle_extractX │ ├── doseCheck_pinnacle_extractX.m │ ├── doseConvert_pinnacle_extractX.m │ ├── doseDownload_pinnacle_extractX.m │ ├── doseInfo_pinnacle_extractX.m │ ├── doseInterp_pinnacle_extractX.m │ ├── doseMachineInfo_pinnacle_extractX.m │ ├── doseRead_pinnacle_extractX.m │ ├── imageConvert_pinnacle_extractX.m │ ├── imageDownload_pinnacle_extractX.m │ ├── imageRead_pinnacle_extractX.m │ ├── roi2Mask_pinnacle_extractX.m │ ├── roiCheck_pinnacle_extractX.m │ ├── roiConvert_pinnacle_extractX.m │ ├── roiDownload_pinnacle_extractX.m │ ├── start_pinnacle_extractX.m │ └── validate_pinnacle_extractX.m ├── read_extractX.m └── roisubvolumes_extractX.m ├── helper ├── create_configX.m ├── dlmcellX.m ├── feature_list.trex ├── filter_list.trex ├── findjobjX.m ├── getDate_logX.m ├── imresize3DX.m ├── logindlg.m ├── notifierX.m ├── readcsvX.m ├── sc │ ├── autumn.m │ ├── bled.m │ ├── bone.m │ ├── bright.m │ ├── cold.m │ ├── cool.m │ ├── copper.m │ ├── copper2.m │ ├── disco.m │ ├── disparity.m │ ├── dusk.m │ ├── earth.m │ ├── gray.m │ ├── hicontrast.m │ ├── hot.m │ ├── hsv.m │ ├── hsv2.m │ ├── imdisp.m │ ├── imsc.m │ ├── jet.m │ ├── pastel.m │ ├── pink.m │ ├── pink2.m │ ├── private │ │ ├── colormap_helper.m │ │ └── rescale.m │ ├── real2rgb.m │ ├── sc.m │ ├── sepia.m │ ├── spring.m │ ├── summer.m │ ├── temp.m │ ├── thermal.m │ ├── whed.m │ └── winter.m ├── splitParser2X.m ├── splitParserX.m ├── subdirX.m └── textParserX.m ├── map ├── Map Parameter Profiles │ ├── misc │ │ ├── zparameters_all.trex │ │ ├── zparameters_new.trex │ │ ├── zparameters_overlaps.trex │ │ └── zparameters_test_t50_1.trex │ ├── parameters_average3_filter.trex │ ├── parameters_average3_filter_15_7.trex │ ├── parameters_default.trex │ ├── parameters_laws_only.trex │ ├── parameters_overlaps.trex │ └── parameters_shifts.trex ├── findmapfiles_mapX.m ├── mapX.fig ├── mapX.m ├── map_comparison │ ├── ccc_mapX.m │ ├── compare_ctX.m │ ├── compare_mapX.m │ ├── mi_mapX.m │ ├── mi_mapX_uint8.m │ ├── outcome_compare_doseX.m │ ├── outcome_compare_dosemapX.m │ ├── outcome_compare_mapX.m │ ├── psnr_mapX.m │ ├── spearman_mapX.m │ └── ssim_mapX.m ├── map_modules │ ├── map_glcm │ │ ├── glcm_map.m │ │ └── glcm_mapX.m │ ├── map_glrlm │ │ ├── glrlm_map.m │ │ └── glrlm_mapX.m │ ├── map_hist │ │ ├── hist_map.m │ │ └── hist_mapX.m │ ├── map_laws2D │ │ ├── laws2D_map.m │ │ └── laws2D_mapX.m │ ├── map_lung │ │ ├── lung_map.m │ │ └── lung_mapX.m │ ├── map_ngtdm │ │ ├── ngtdm_map.m │ │ └── ngtdm_mapX.m │ ├── map_shape │ │ ├── shape_map.m │ │ └── shape_mapX.m │ ├── mask_points.m │ └── random2D_mask_points.m ├── map_parameters │ ├── parameterfields_mapX.m │ ├── parameters_mapX.m │ ├── profileread_mapX.m │ └── profilewrite_mapX.m ├── move_mapX.m ├── nanconv_mapX.m ├── norm_mapX.m ├── nuke_mapX.m ├── percentile_mapX.m ├── read_mapX.m ├── standardize_mapX.m ├── start_mapX.m ├── startmodule_mapX.m └── vector2array_mapX.m ├── misc ├── Figure TREX 1.png ├── Figure TREX 2.png ├── Figure TREX 3.png ├── Figure TREX 4.png ├── Figure TREX 5.png ├── appendix_dosimetric.pdf └── appendix_radiomics.pdf ├── project ├── batchX │ ├── addjobX.fig │ ├── addjobX.m │ ├── batchX.fig │ └── batchX.m ├── cleanup_logX.m ├── cleanup_projectX.m ├── cleanup_roidataX.m ├── migration_projectX.m ├── projectX.fig ├── projectX.m ├── reformat_projectX.m ├── update_projectX.m └── writeX │ ├── combine_writeX.m │ ├── link_writeX.fig │ ├── link_writeX.m │ ├── writeX.fig │ └── writeX.m ├── setup ├── axes_main_setupX.m ├── axes_minor1_setupX.m ├── axes_minor2_setupX.m ├── pinnacle_setupX.fig ├── pinnacle_setupX.m ├── pinnacle_setupX │ ├── dicomInfo_pinnacle_setupX.m │ ├── doseInfo_pinnacle_setupX.m │ ├── drop_dose_pinnacle_setupX.m │ ├── drop_institution_pinnacle_setupX.m │ ├── drop_patient_pinnacle_setupX.m │ ├── drop_plan_pinnacle_setupX.m │ ├── drop_roi_pinnacle_setupX.m │ ├── drop_server_pinnacle_setupX.m │ ├── handlesoff_pinnacle_setupX.m │ ├── imageInfo_pinnacle_setupX.m │ ├── initialize_pinnacle_setupX.m │ ├── interpDose_pinnacle_setupX.m │ ├── machineInfo_pinnacle_setupX.m │ ├── pinnacle_setup_advanced │ │ ├── advanced_pinnacle_setupX.fig │ │ ├── advanced_pinnacle_setupX.m │ │ ├── axes_mask_advanced_pinnacle_setupX.m │ │ └── pinnacle_roi2Mask_setupX.m │ ├── pinnacle_setup_script │ │ ├── add_10Gy_region_contours.m │ │ ├── add_10Gy_shell_contours.m │ │ ├── add_10Gy_shell_deformedcontours.m │ │ ├── add_10Gy_shell_dose.m │ │ ├── add_all_contours.m │ │ └── add_subvolumes.m │ ├── push_add_pinnacle_setupX.m │ ├── push_institution_pinnacle_setupX.m │ ├── push_patient_pinnacle_setupX.m │ ├── push_plan_pinnacle_setupX.m │ ├── push_server_pinnacle_setupX.m │ ├── readDose_pinnacle_setupX.m │ ├── readImg_pinnacle_setupX.m │ ├── readROI_pinnacle_setupX.m │ ├── resetexport_pinnacle_setupX.m │ ├── restorehandles_pinnacle_setupX.m │ ├── scaleCurvedata_pinnacle_setupX.m │ ├── subvolumes_pinnacle_setupX.fig │ ├── subvolumes_pinnacle_setupX.m │ ├── suspendhandles_pinnacle_setupX.m │ ├── view_doseinfo_pinnacle_setupX.fig │ ├── view_doseinfo_pinnacle_setupX.m │ ├── view_scaninfo_pinnacle_setupX.fig │ └── view_scaninfo_pinnacle_setupX.m ├── read_setupX.m └── save_setupX.m ├── texture ├── Texture Parameter Profiles │ ├── parameters_8bitonly.trex │ ├── parameters_default.trex │ └── parameters_shape_only.trex ├── read_textureX.m ├── remove_textureX.m ├── start_textureX.m ├── startmodule_textureX.m ├── tex_modules │ ├── tex_glcm │ │ ├── glcm_features.m │ │ ├── glcm_halveNL.m │ │ ├── glcm_matrix3D.m │ │ ├── glcm_nonDirMatrix.m │ │ └── glcm_textureX.m │ ├── tex_glrlm │ │ ├── glrlm_features.m │ │ ├── glrlm_matrix3D.m │ │ ├── glrlm_orderMatrix.m │ │ └── glrlm_textureX.m │ ├── tex_hist │ │ ├── hist_features.m │ │ └── hist_textureX.m │ ├── tex_laws2D │ │ ├── laws2D_features.m │ │ └── laws2D_textureX.m │ ├── tex_lung │ │ ├── lung_features.m │ │ └── lung_textureX.m │ ├── tex_ngtdm │ │ ├── ngtdm_features.m │ │ ├── ngtdm_matrix3D.m │ │ ├── ngtdm_textureX.m │ │ └── ngtdm_weighted_matrix3D.m │ └── tex_shape │ │ ├── shape_features.m │ │ └── shape_textureX.m ├── tex_parameters │ ├── parameterfields_textureX.m │ ├── parameters_textureX.m │ ├── profileread_textureX.m │ └── profilewrite_textureX.m ├── tex_prep │ ├── prepCT.m │ ├── prepCrop.m │ ├── prepPreprocess.m │ └── tex_preprocess │ │ ├── not currently used │ │ ├── filter_addnoise.m │ │ ├── filter_adplocalnoise.m │ │ ├── filter_adpmedian.m │ │ ├── filter_alphatrim.m │ │ ├── filter_ave.m │ │ ├── filter_charmean.m │ │ ├── filter_gaussian.m │ │ ├── filter_gmean.m │ │ ├── filter_harmean.m │ │ ├── filter_laplacian.m │ │ ├── filter_log.m │ │ ├── filter_max.m │ │ ├── filter_median.m │ │ ├── filter_midpoint.m │ │ ├── filter_min.m │ │ ├── filter_wiener.m │ │ └── imnoise2.m │ │ ├── preprocess_filter_ave_hsize3.m │ │ ├── preprocess_filter_gradient2D.m │ │ ├── preprocess_filter_gradient3D.m │ │ ├── preprocess_filter_localentropy.m │ │ ├── preprocess_filter_localrange.m │ │ ├── preprocess_filter_localstd.m │ │ ├── preprocess_filter_log_hsize10_sigma2.m │ │ ├── preprocess_filter_log_hsize12_sigma2_5.m │ │ ├── preprocess_filter_log_hsize4_sigma1.m │ │ ├── preprocess_filter_log_hsize6_sigma1_5.m │ │ ├── preprocess_filter_log_hsize8_sigma1_8.m │ │ ├── preprocess_threshold.m │ │ ├── preprocess_threshold250.m │ │ ├── preprocess_threshold500.m │ │ ├── preprocess_threshold750.m │ │ └── read_preprocess.m ├── textureX.fig ├── textureX.m └── write_textureX.m ├── utilities ├── correct2BaselineX.m ├── data_exportX.m ├── dicom_fields.trex ├── fix_bug_pinnaclectX.m ├── oldROI_deleteX.m ├── pinnacle_imageX.fig ├── pinnacle_imageX.m ├── projectmodules_copyX.m ├── rawdvh_exportX.m ├── readImg_dicomX.m ├── reduce_trexdata.m ├── scanDir_dicomX.m ├── totallung_correct2BaselineX.m └── verify_pinnaclectX.m └── viewer ├── axes_main_viewerX.m ├── axes_minor1_viewerX.m ├── axes_minor2_viewerX.m ├── scaleCurvedata_viewerX.m ├── viewerX.fig └── viewerX.m /.gitignore: -------------------------------------------------------------------------------- 1 | ~*.m 2 | 3 | 4 | *.db 5 | -------------------------------------------------------------------------------- /TREX Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/TREX Icon.png -------------------------------------------------------------------------------- /TREX Title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/TREX Title.png -------------------------------------------------------------------------------- /TREX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/TREX.fig -------------------------------------------------------------------------------- /Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/Thumbs.db -------------------------------------------------------------------------------- /config.trex: -------------------------------------------------------------------------------- 1 | notifier-mail = 2 | notifier-password = 3 | pinnacle-server = Pinnacle-Research 4 | default-project = 5 | default-directory = 6 | -------------------------------------------------------------------------------- /credits.trex: -------------------------------------------------------------------------------- 1 | #Rolled into trex 2 | dlmcell: https://www.mathworks.com/matlabcentral/fileexchange/25387-write-cell-array-to-text-file 3 | subdir: https://github.com/kakearney/subdir-pkg 4 | sc: https://github.com/ojwoodford/sc 5 | notifier: https://www.mathworks.com/matlabcentral/fileexchange/28733-notifier 6 | findobj: https://www.mathworks.com/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects 7 | logindlg: https://www.mathworks.com/matlabcentral/fileexchange/8499-login 8 | ccc calculation: https://github.com/zuoxinian/CCS 9 | 3d gamma: http://www.mistir.info/3d-gamma 10 | nancov: https://www.mathworks.com/matlabcentral/fileexchange/41961-nanconv/content/nanconv.m 11 | 12 | #Inspiration 13 | CERR 14 | IBEX 15 | Undocumented Matlab -------------------------------------------------------------------------------- /dose/Dose Parameter Profiles/parameters_default.trex: -------------------------------------------------------------------------------- 1 | dvh,toggle,on 2 | plan,toggle,on 3 | location,toggle,on 4 | spatialdvh,toggle,on 5 | spatialdvh,weight,Radial_XY 6 | spatialdvh,weight,Sup_Inf 7 | spatialdvh,weight,Ant_Post 8 | spatialdvh,weight,Right_Left 9 | -------------------------------------------------------------------------------- /dose/Dose Parameter Profiles/parameters_default_and_subsetmaps.trex: -------------------------------------------------------------------------------- 1 | dvh,toggle,on 2 | plan,toggle,on 3 | location,toggle,on 4 | spatialdvh,toggle,on 5 | spatialdvh,weight,Radial_XY 6 | spatialdvh,weight,Sup_Inf 7 | spatialdvh,weight,Ant_Post 8 | spatialdvh,weight,Right_Left 9 | mapdvh,toggle,on 10 | mapdvh,map,HIST.MAP.31.15.0.None.2D.Sum 11 | mapdvh,map,HIST.MAP.31.15.0.None.2D.Mean 12 | mapdvh,map,HIST.MAP.31.15.0.None.2D.Per10 13 | mapdvh,map,HIST.MAP.31.15.0.None.2D.Per25 14 | mapdvh,map,HIST.MAP.31.15.0.None.2D.Per90 15 | mapdvh,map,HIST.MAP.31.15.0.None.2D.Per95 16 | mapdvh,map,HIST.MAP.31.15.0.None.2D.Entropy 17 | mapdvh,map,HIST.MAP.31.15.0.None.2D.Energy 18 | mapdvh,map,HIST.MAP.31.15.0.None.2D.RMS 19 | mapdvh,map,GLCM.MAP.31.15.0.None.8.[0 4095].1.2D.Entropy 20 | mapdvh,map,GLCM.MAP.31.15.0.None.8.[0 4095].1.2D.Homogeneity1 21 | mapdvh,map,GLCM.MAP.31.15.0.None.8.[0 4095].1.2D.SumAverage 22 | mapdvh,map,GLCM.MAP.31.15.0.None.8.[0 4095].1.2D.SumEntropy 23 | mapdvh,map,GLRLM.MAP.31.15.0.None.8.[0 4095].2D.GLNU 24 | mapdvh,map,GLRLM.MAP.31.15.0.None.8.[0 4095].2D.HGRE 25 | mapdvh,map,GLRLM.MAP.31.15.0.None.8.[0 4095].2D.SRHGE 26 | mapdvh,map,LAWS2D.MAP.31.15.0.None.2D.L5L5_Mean 27 | mapdvh,map,LAWS2D.MAP.31.15.0.None.2D.L5L5_Energy 28 | mapdvh,map,LAWS2D.MAP.31.15.0.None.2D.L5L5_RMS 29 | mapdvh,map,LAWS2D.MAP.31.15.0.None.2D.L5E5_Energy 30 | mapdvh,map,LAWS2D.MAP.31.15.0.None.2D.L5E5_RMS 31 | mapdvh,map,LAWS2D.MAP.31.15.0.None.2D.L5S5_Energy 32 | mapdvh,map,LUNG.MAP.31.15.0.None.2D.LAA856 33 | mapdvh,map,LUNG.MAP.31.15.0.None.2D.Reserve 34 | -------------------------------------------------------------------------------- /dose/doseX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/dose/doseX.fig -------------------------------------------------------------------------------- /dose/dose_modules/dose_dvh/dvh_doseX.m: -------------------------------------------------------------------------------- 1 | function [test_missing] = dvh_doseX(extractRead_entry,test_missing) 2 | %% Do some preallocation... 3 | num_mising = numel(test_missing.module); 4 | 5 | stats = dvh_features(1); 6 | featureNames = fieldnames(stats); 7 | for nameCount = 1:length(featureNames) 8 | test_missing.(['feature_',featureNames{nameCount}]) = nan(num_mising,1); 9 | end 10 | test_missing.bins_dvh = cell(num_mising,1); 11 | test_missing.diff_dvh = cell(num_mising,1); 12 | test_missing.cumul_dvh = cell(num_mising,1); 13 | 14 | %% Load the data, do some sanity checks of the passed data first 15 | project_patient = unique(extractRead_entry.project_patient); 16 | image_file = unique(extractRead_entry.image_file); 17 | roi_file = unique(extractRead_entry.roi_file); 18 | if numel(project_patient) == 1 && numel(image_file) == 1 && numel(roi_file) == 1 19 | project_patient = project_patient{1}; 20 | image_file = image_file{1}; 21 | roi_file = roi_file{1}; 22 | else 23 | error('All of the data in extractRead_entry should have the same project_patient, image_file, and roi_file') 24 | end 25 | dose_file = extractRead_entry.dose_file; 26 | dose_file = dose_file{1}; 27 | 28 | %% 29 | if ~isempty(dose_file) 30 | dose = load(fullfile(project_patient,dose_file),'array'); 31 | dose = dose.array; 32 | 33 | mask = load(fullfile(project_patient,roi_file),'mask'); 34 | mask = mask.mask; 35 | 36 | xV = load(fullfile(project_patient,image_file),'array_xV'); 37 | xV = xV.array_xV; 38 | yV = load(fullfile(project_patient,image_file),'array_yV'); 39 | yV = yV.array_yV; 40 | zV = load(fullfile(project_patient,image_file),'array_zV'); 41 | zV = zV.array_zV; 42 | 43 | vol_vox = abs(mean(diff(xV))*mean(diff(yV))*mean(diff(zV))); 44 | clear xV yV zV 45 | 46 | bin_size = 1; 47 | [stats,doseBins,volHist,cumVolHist] = dvh_features(mask,dose,vol_vox,bin_size); 48 | 49 | for nameCount = 1:length(featureNames) 50 | test_missing.(['feature_',featureNames{nameCount}]) = stats.(featureNames{nameCount}); 51 | end 52 | 53 | test_missing.bins_dvh = {doseBins}; 54 | test_missing.diff_dvh = {volHist}; 55 | test_missing.cumul_dvh = {cumVolHist}; 56 | end 57 | 58 | %% 59 | clearvars -except test_missing 60 | -------------------------------------------------------------------------------- /dose/dose_modules/dose_location/location_doseX.m: -------------------------------------------------------------------------------- 1 | function [test_missing] = location_doseX(extractRead_entry,test_missing) 2 | %% Do some preallocation... 3 | num_mising = numel(test_missing.module); 4 | 5 | stats = location_features(1); 6 | featureNames = fieldnames(stats); 7 | for nameCount = 1:length(featureNames) 8 | test_missing.(['feature_',featureNames{nameCount}]) = nan(num_mising,1); 9 | end 10 | 11 | %% Load the data, do some sanity checks of the passed data first 12 | project_patient = unique(extractRead_entry.project_patient); 13 | image_file = unique(extractRead_entry.image_file); 14 | roi_file = unique(extractRead_entry.roi_file); 15 | if numel(project_patient) == 1 && numel(image_file) == 1 && numel(roi_file) == 1 16 | project_patient = project_patient{1}; 17 | image_file = image_file{1}; 18 | roi_file = roi_file{1}; 19 | else 20 | error('All of the data in extractRead_entry should have the same project_patient, image_file, and roi_file') 21 | end 22 | 23 | %% 24 | mask = load(fullfile(project_patient,roi_file),'mask'); 25 | mask = mask.mask; 26 | 27 | xV = load(fullfile(project_patient,image_file),'array_xV'); 28 | xV = xV.array_xV; 29 | yV = load(fullfile(project_patient,image_file),'array_yV'); 30 | yV = yV.array_yV; 31 | zV = load(fullfile(project_patient,image_file),'array_zV'); 32 | zV = zV.array_zV; 33 | 34 | stats = location_features(mask,xV,yV,zV); 35 | 36 | for nameCount = 1:length(featureNames) 37 | test_missing.(['feature_',featureNames{nameCount}]) = stats.(featureNames{nameCount}); 38 | end 39 | 40 | %% 41 | clearvars -except test_missing 42 | -------------------------------------------------------------------------------- /dose/dose_modules/dose_plan/plan_doseX.m: -------------------------------------------------------------------------------- 1 | function [test_missing] = plan_doseX(extractRead_entry,test_missing) 2 | %% Do some preallocation... 3 | num_mising = numel(test_missing.module); 4 | 5 | stats = plan_features(1); 6 | featureNames = fieldnames(stats); 7 | for nameCount = 1:length(featureNames) 8 | test_missing.(['feature_',featureNames{nameCount}]) = cell(num_mising,1); 9 | end 10 | 11 | %% Load the data, do some sanity checks of the passed data first 12 | project_patient = unique(extractRead_entry.project_patient); 13 | image_file = unique(extractRead_entry.image_file); 14 | roi_file = unique(extractRead_entry.roi_file); 15 | if numel(project_patient) == 1 && numel(image_file) == 1 && numel(roi_file) == 1 16 | project_patient = project_patient{1}; 17 | image_file = image_file{1}; 18 | roi_file = roi_file{1}; 19 | else 20 | error('All of the data in extractRead_entry should have the same project_patient, image_file, and roi_file') 21 | end 22 | dose_file = extractRead_entry.dose_file; 23 | dose_file = dose_file{1}; 24 | 25 | %% 26 | if ~isempty(dose_file) 27 | dose = load(fullfile(project_patient,dose_file)); 28 | 29 | stats = plan_features(dose); 30 | 31 | for nameCount = 1:length(featureNames) 32 | test_missing.(['feature_',featureNames{nameCount}]) = {stats.(featureNames{nameCount})}; 33 | end 34 | end 35 | %% 36 | clearvars -except test_missing 37 | -------------------------------------------------------------------------------- /dose/dose_modules/dose_spatialdvh/spatialdvh_weight.m: -------------------------------------------------------------------------------- 1 | function [weight] = spatialdvh_weight(siz,scheme) 2 | % Creates and outputs weighting matrices with the given size and scheme. 3 | % 4 | % Input parameters: 5 | % 6 | % 'siz' A 1x3 input vector containing the desired dimensions of 7 | % the resulting weighting array. 8 | % 9 | % 'scheme' An input string indicating the desired type of 10 | % weighting matrix. See the options below for the 11 | % available options. 12 | % 13 | % Output parameters: 14 | % 15 | % 'weight' The output weighting matrix. 16 | % 17 | % Notes: 18 | % 19 | % SPK 20 | 21 | weight = zeros(siz); 22 | ydim = siz(1); 23 | xdim = siz(2); 24 | zdim = siz(3); 25 | 26 | ycent = round(ydim/2); 27 | xcent = round(xdim/2); 28 | zcent = round(zdim/2); 29 | 30 | switch scheme 31 | case 'Radial_XY' 32 | for i =1:ydim 33 | for j = 1:xdim 34 | for k = 1:zdim 35 | weight(i,j,k) = sqrt((j-xcent)^2/xcent^2+(i-ycent)^2/ycent^2); 36 | end 37 | end 38 | end 39 | 40 | case 'Sup_Inf' 41 | line = linspace(0,1,round(zdim)); 42 | weight = permute(repmat(line,[ydim,1,xdim]),[1 3 2]); 43 | 44 | case 'Ant_Post' 45 | line = linspace(0,1,round(ydim)); 46 | weight = permute(repmat(line,[zdim,1,xdim]),[2 3 1]); 47 | 48 | case 'Right_Left' 49 | line = linspace(0,1,round(xdim)); 50 | weight = permute(repmat(line,[zdim,1,ydim]),[3 2 1]); 51 | 52 | otherwise 53 | error('here') 54 | end 55 | 56 | %% 57 | clearvars -except weight 58 | -------------------------------------------------------------------------------- /dose/dose_parameters/parameterfields_doseX.m: -------------------------------------------------------------------------------- 1 | function [h] = parameterfields_doseX(varargin) 2 | 3 | project_path = []; 4 | 5 | if nargin == 1 6 | h = varargin{1}; 7 | elseif nargin == 2 8 | h = varargin{1}; 9 | project_path = varargin{2}; 10 | else 11 | h = []; 12 | h.profile = cell(0); 13 | end 14 | 15 | h.module_names = {'dvh','plan','location','spatialdvh','mapdvh'}; 16 | 17 | %-------------------------------------------------------------------------- 18 | %% These are all defined explicitly because some parameters are dependent on the module 19 | h.dvh = []; 20 | h.dvh.toggle = []; 21 | 22 | h.plan = []; 23 | h.plan.toggle = []; 24 | 25 | h.location = []; 26 | h.location.toggle = []; 27 | 28 | % h.dmh = []; 29 | % h.dmh.toggle = []; 30 | 31 | h.spatialdvh = []; 32 | h.spatialdvh.toggle = []; 33 | h.spatialdvh.weight = cell(0); 34 | 35 | h.mapdvh = []; 36 | h.mapdvh.toggle = []; 37 | h.mapdvh.map = cell(0); 38 | 39 | %-------------------------------------------------------------------------- 40 | %% All of the potential parameters that are used (column vectors!) 41 | 42 | h.param_fields = {'toggle','weight','map'}; 43 | 44 | h.toggle = [false; true]; 45 | h.toggle_strings = {'Off'; 'On'}; 46 | 47 | h.weight = {'Radial_XY'; 'Sup_Inf'; 'Ant_Post'; 'Right_Left'}; 48 | 49 | %% 50 | h.map_modules = {'hist','glcm','glrlm','ngtdm','laws2D','lung','shape'}; 51 | h.map = cell(0); 52 | 53 | if ~isempty(project_path) 54 | % Get unique map filenames 55 | for mCount = 1:numel(h.map_modules) 56 | moduleRead = read_mapX(project_path,h.map_modules{mCount},false); 57 | %h.map = [h.map; unique(strrep(moduleRead.map_file, moduleRead.roi_file,''))]; 58 | 59 | temp.map = unique(strrep(moduleRead.map_file, moduleRead.roi_file,'')); 60 | 61 | stats = feval([h.map_modules{mCount},'_features'],1); 62 | featureNames = fieldnames(stats); 63 | 64 | for j = 1:numel(temp.map) 65 | for i = 1:numel(featureNames) 66 | h.map = [h.map; [temp.map{j},featureNames{i}]]; 67 | end 68 | end 69 | end 70 | end 71 | 72 | %% 73 | clearvars -except h 74 | -------------------------------------------------------------------------------- /dose/dose_parameters/profileread_doseX.m: -------------------------------------------------------------------------------- 1 | function [h] = profileread_doseX(h,profile) 2 | %% Read parameter profile list and sort into appropriate fields 3 | for i = 1:size(profile,1) 4 | module = profile{i,1}; 5 | parameter = profile{i,2}; 6 | 7 | if strcmpi(parameter,'toggle') 8 | h.(module).(parameter) = profile{i,3}; 9 | else 10 | h.(module).(parameter){end+1,1} = profile{i,3}; 11 | end 12 | end 13 | 14 | %% 15 | clearvars -except h 16 | -------------------------------------------------------------------------------- /dose/dose_parameters/profilewrite_doseX.m: -------------------------------------------------------------------------------- 1 | function [profile] = profilewrite_doseX(h) 2 | %%Write the texture parameter profile to a cell array. 3 | profile = cell(0); 4 | 5 | for i = 1:numel(h.module_names) 6 | module = h.module_names{i}; 7 | parameters = fieldnames(h.(module)); 8 | 9 | for j = 1:numel(parameters) 10 | if ischar(h.(module).(parameters{j})) 11 | profile{end+1,1} = module; 12 | profile{end,2} = parameters{j}; 13 | profile{end,3} = h.(module).(parameters{j}); 14 | 15 | else 16 | for k = 1:numel(h.(module).(parameters{j})) 17 | profile{end+1,1} = module; 18 | profile{end,2} = parameters{j}; 19 | profile{end,3} = h.(module).(parameters{j}){k}; 20 | end 21 | end 22 | end 23 | end 24 | 25 | %% 26 | clearvars -except profile 27 | -------------------------------------------------------------------------------- /dose/remove_doseX.m: -------------------------------------------------------------------------------- 1 | function remove_doseX(project_path) 2 | %% Remove each module.mat 3 | h = parameterfields_doseX(); 4 | for i = 1:numel(h.module_names) 5 | filename = [upper(h.module_names{i}),'.mat']; 6 | if exist(fullfile(project_path,filename),'file') == 2 7 | delete(fullfile(project_path,filename)) 8 | end 9 | end 10 | 11 | %% 12 | clearvars 13 | -------------------------------------------------------------------------------- /dose/start_doseX.m: -------------------------------------------------------------------------------- 1 | function [h] = start_doseX(h) 2 | %% 3 | set(h.push_start,'Enable','off') 4 | start = tic; 5 | 6 | remove_doseX(h.project_path) 7 | 8 | disp('TREX-RT>> Dose data extraction started...') 9 | 10 | %% Run each module 11 | for i = 1:numel(h.module_names) 12 | module = h.module_names{i}; 13 | 14 | if strcmpi(h.(module).toggle,'on') 15 | [h] = startmodule_doseX(h,module); 16 | end 17 | 18 | pause(0.001) 19 | end 20 | 21 | %% 22 | set(h.text_wait2,'String','Dose extraction complete!') 23 | drawnow; pause(0.001); 24 | disp('TREX-RT>> Dose Data Extraction Complete!') 25 | disp(['TREX-RT>> Total DoseX run time: ',num2str(toc(start)),' seconds']) 26 | 27 | %% 28 | clearvars -except h hObject 29 | -------------------------------------------------------------------------------- /extract/extractX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/extract/extractX.fig -------------------------------------------------------------------------------- /extract/pinnacle_extractX/doseConvert_pinnacle_extractX.m: -------------------------------------------------------------------------------- 1 | function [extractWrite] = doseConvert_pinnacle_extractX(extractWrite,extractRead,entry) 2 | %% 3 | if strcmpi(extractWrite.dose_name,'') || isempty(extractWrite.dose_name) 4 | 5 | else 6 | %Look for the converted image 7 | files = dir(extractWrite.project_patient); 8 | 9 | found = false; 10 | for i = 1:numel(files) 11 | if strcmpi(files(i).name,extractWrite.dose_file) 12 | found = true; 13 | break 14 | end 15 | end 16 | 17 | %If not found, then convert it... 18 | if ~found 19 | disp(['TREX-RT>> Entry ',num2str(entry),': Reading dose data...']) 20 | 21 | dose = doseInfo_pinnacle_extractX(extractWrite); 22 | dose = doseMachineInfo_pinnacle_extractX(extractWrite,dose); 23 | dose = doseRead_pinnacle_extractX(extractWrite,dose); 24 | dose = doseInterp_pinnacle_extractX(extractWrite,entry,dose); 25 | 26 | extractWrite.convertDose = true; 27 | extractWrite.convertDose_datestr = datestr(now,'yyyymmddHHMMSS'); 28 | 29 | save(fullfile(extractWrite.project_patient,extractWrite.dose_file),'-struct','dose') 30 | save(fullfile(extractWrite.project_patient,extractWrite.dose_file),'-struct','extractWrite','-append') 31 | 32 | disp(['TREX-RT>> Entry ',num2str(entry),': Dose data saved ',extractWrite.dose_file]) 33 | else 34 | extractWrite.convertDose = true; 35 | extractWrite.convertDose_datestr = extractRead.convertDose_datestr; 36 | end 37 | end 38 | 39 | %% 40 | clearvars -except extractWrite 41 | -------------------------------------------------------------------------------- /extract/pinnacle_extractX/doseInterp_pinnacle_extractX.m: -------------------------------------------------------------------------------- 1 | function [dose] = doseInterp_pinnacle_extractX(extractWrite,entry,dose) 2 | %% 3 | disp(['TREX-RT>> Entry ',num2str(entry),': Interpolating dose array']) 4 | 5 | dose.array_xV = load(fullfile(extractWrite.project_patient,extractWrite.image_file),'array_xV'); 6 | dose.array_xV = dose.array_xV.array_xV; 7 | dose.array_yV = load(fullfile(extractWrite.project_patient,extractWrite.image_file),'array_yV'); 8 | dose.array_yV = dose.array_yV.array_yV; 9 | dose.array_zV = load(fullfile(extractWrite.project_patient,extractWrite.image_file),'array_zV'); 10 | dose.array_zV = dose.array_zV.array_zV; 11 | 12 | [xi,yi,zi] = meshgrid(single(dose.array_xV),... 13 | single(dose.array_yV),... 14 | single(dose.array_zV)); 15 | 16 | [x,y,z] = meshgrid(single(dose.original.xV),... 17 | single(dose.original.yV),... 18 | single(dose.original.zV)); 19 | 20 | dose.array = interp3(x,y,z,dose.original.array,xi,yi,zi,'linear'); 21 | 22 | %% 23 | clearvars -except dose 24 | -------------------------------------------------------------------------------- /extract/pinnacle_extractX/doseMachineInfo_pinnacle_extractX.m: -------------------------------------------------------------------------------- 1 | function dose = doseMachineInfo_pinnacle_extractX(extractWrite,dose) 2 | %% 3 | fid = fopen(fullfile(extractWrite.project_dosedata,'plan.Pinnacle.Machines')); 4 | machinedata = textscan(fid,'%s','delimiter','\n'); 5 | machinedata = machinedata{1}; 6 | fclose(fid); 7 | 8 | [~,rows] = splitParserX(machinedata,'VersionTimestamp '); 9 | rows = rows-3; 10 | 11 | machines = []; 12 | if isempty(rows) 13 | machines = machinedata; 14 | else 15 | for i = 1:numel(rows) 16 | if i == numel(rows) 17 | machines{end+1,1} = machinedata(rows(i):end); 18 | else 19 | machines{end+1,1} = machinedata(rows(i):rows(i+1)-1); 20 | end 21 | end 22 | end 23 | 24 | for i = 1:numel(machines) 25 | dose.machine(i).Name = textParserX(machines{i},'Name '); 26 | dose.machine(i).MachineType = textParserX(machines{i},'MachineType '); 27 | dose.machine(i).VersionTimestamp = textParserX(machines{i},'VersionTimestamp '); 28 | 29 | dose.machine(i).MachineNameAndVersion = [dose.machine(i).Name,': ',dose.machine(i).VersionTimestamp]; 30 | 31 | photonlist = splitParserX(machines{i},'PhotonEnergyList ={'); 32 | photonlist = photonlist{1}; 33 | electronlist = splitParserX(machines{i},'ElectronEnergyList ={'); 34 | electronlist = electronlist{1}; 35 | 36 | photonlist = photonlist(1:(numel(photonlist)-numel(electronlist))); 37 | clear electronlist 38 | 39 | photonenergies = splitParserX(photonlist,'MachineEnergy ={'); 40 | clear photonlist 41 | 42 | for j = 1:numel(photonenergies) 43 | dose.machine(i).photon(j).Value = str2double(textParserX(photonenergies{j},'Value ')); 44 | dose.machine(i).photon(j).Name = textParserX(photonenergies{j},'Name '); 45 | dose.machine(i).photon(j).ReferenceDepth = str2double(textParserX(photonenergies{j},'ReferenceDepth ')); 46 | dose.machine(i).photon(j).SourceToCalibrationPointDistance = str2double(textParserX(photonenergies{j},'SourceToCalibrationPointDistance ')); 47 | dose.machine(i).photon(j).DosePerMuAtCalibration = str2double(textParserX(photonenergies{j},'DosePerMuAtCalibration ')); 48 | dose.machine(i).photon(j).CalculatedCalibrationDose = str2double(textParserX(photonenergies{j},'CalculatedCalibrationDose ')); 49 | end 50 | clear photonenergies 51 | end 52 | clear machines 53 | 54 | %% 55 | clearvars -except dose 56 | -------------------------------------------------------------------------------- /extract/pinnacle_extractX/doseRead_pinnacle_extractX.m: -------------------------------------------------------------------------------- 1 | function [dose] = doseRead_pinnacle_extractX(extractWrite,dose) 2 | %% 3 | dosedim = [dose.original.ydim,dose.original.xdim,dose.original.zdim]; 4 | dose.original.array = zeros(dosedim); 5 | 6 | for i = 1:numel(dose.beam) 7 | %Find the dose/mu calibration factor 8 | dosemu = []; 9 | for j = 1:numel(dose.machine) 10 | if strcmpi(dose.machine(j).MachineNameAndVersion,dose.beam(i).MachineNameAndVersion) 11 | for k = 1:numel(dose.machine(j).photon) 12 | if strcmpi(dose.machine(j).photon(k).Name,dose.beam(i).MachineEnergyName) 13 | dosemu = dose.machine(j).photon(k).DosePerMuAtCalibration; 14 | break 15 | end 16 | end 17 | end 18 | end 19 | 20 | filename = dose.beam(i).DoseVolume; 21 | filename = filename(regexpi(filename,'[0-9]')); 22 | 23 | while length(filename) < 3 24 | filename = ['0',filename]; 25 | end 26 | 27 | filename = ['plan.Trial.binary.',filename]; 28 | 29 | fid = fopen(fullfile(extractWrite.project_dosedata,filename),'r','b'); 30 | dosebeam = fread(fid,prod(dosedim),'single=>single'); 31 | fclose(fid); 32 | 33 | dosebeam = reshape(dosebeam,dosedim([2 1 3])); 34 | dosebeam = permute(dosebeam,[2 1 3]); 35 | 36 | for j = 1:numel(dose.prescription) 37 | if strcmpi(dose.prescription(j).Name,dose.beam(i).PrescriptionName) 38 | break 39 | end 40 | end 41 | 42 | dosebeam = dosebeam*... 43 | dose.prescription(j).NumberOfFractions*... 44 | dose.beam(i).PrescriptionDose/... 45 | (dose.beam(i).NormalizedDose*... 46 | dose.beam(i).CollimatorOutputFactor*... 47 | dose.beam(i).TotalTransmissionFraction*... 48 | dosemu); 49 | 50 | if sum(isnan(dosebeam(:))) ~= numel(dosebeam) 51 | dose.original.array = dose.original.array + dosebeam; 52 | end 53 | end 54 | 55 | %% 56 | clearvars -except dose 57 | -------------------------------------------------------------------------------- /extract/pinnacle_extractX/imageConvert_pinnacle_extractX.m: -------------------------------------------------------------------------------- 1 | function [extractWrite] = imageConvert_pinnacle_extractX(extractWrite,extractRead,entry) 2 | %% 3 | %Look for the converted image 4 | files = dir(extractWrite.project_patient); 5 | 6 | found = false; 7 | for i = 1:numel(files) 8 | if strcmpi(files(i).name,extractWrite.image_file) 9 | found = true; 10 | break 11 | end 12 | end 13 | 14 | %If not found, then convert it... 15 | if ~found 16 | disp(['TREX-RT>> Entry ',num2str(entry),': Reading image...']) 17 | 18 | image = imageRead_pinnacle_extractX(extractWrite); 19 | 20 | extractWrite.convertImage = true; 21 | extractWrite.convertImage_datestr = datestr(now,'yyyymmddHHMMSS'); 22 | 23 | save(fullfile(extractWrite.project_patient,extractWrite.image_file),'-struct','image') 24 | save(fullfile(extractWrite.project_patient,extractWrite.image_file),'-struct','extractWrite','-append') 25 | 26 | disp(['TREX-RT>> Entry ',num2str(entry),': Image saved ',extractWrite.image_file]) 27 | else 28 | extractWrite.convertImage = true; 29 | extractWrite.convertImage_datestr = extractRead.convertImage_datestr; 30 | end 31 | 32 | %% 33 | clearvars -except extractWrite 34 | -------------------------------------------------------------------------------- /extract/pinnacle_extractX/imageRead_pinnacle_extractX.m: -------------------------------------------------------------------------------- 1 | function [image] = imageRead_pinnacle_extractX(extractWrite) 2 | %% 3 | image.array = []; 4 | 5 | image.array_xV = extractWrite.image_xstart : extractWrite.image_xpixdim : extractWrite.image_xstart + (extractWrite.image_xdim-1)*extractWrite.image_xpixdim; 6 | image.array_yV = fliplr(extractWrite.image_ystart : extractWrite.image_ypixdim : extractWrite.image_ystart + (extractWrite.image_ydim-1)*extractWrite.image_ypixdim); 7 | % image.array_zV = extractWrite.image_zstart : extractWrite.image_zpixdim : extractWrite.image_zstart + (extractWrite.image_zdim-1)*extractWrite.image_zpixdim; 8 | 9 | fid = fopen(fullfile(extractWrite.project_scandata,[extractWrite.image_name,'.ImageInfo'])); 10 | imageInfo = textscan(fid,'%s','delimiter','\n'); 11 | imageInfo = imageInfo{1}; 12 | fclose(fid); 13 | imageInfo = splitParserX(imageInfo,'ImageInfo ={'); 14 | 15 | image.array_zV = zeros(1,numel(imageInfo)); 16 | for i = 1:numel(imageInfo) 17 | image.array_zV(1,i) = str2double(textParserX(imageInfo{i},'TablePosition = ')); 18 | end 19 | clear imageInfo 20 | 21 | image.array = zeros([extractWrite.image_ydim,extractWrite.image_xdim,extractWrite.image_zdim],'uint16'); 22 | 23 | if extractWrite.image_byteorder == 0 24 | byte_order = 'l'; 25 | else 26 | byte_order = 'b'; 27 | end 28 | 29 | if extractWrite.image_bitpix ~= 16 30 | error('Image bitpix not 16') 31 | end 32 | 33 | fid = fopen(fullfile(extractWrite.project_scandata,[extractWrite.image_name,'.img'])); 34 | for i=1:extractWrite.image_zdim 35 | image.array(:,:,i) = reshape(fread(fid,extractWrite.image_xdim*extractWrite.image_ydim,'uint16',byte_order),extractWrite.image_ydim,extractWrite.image_xdim)'; 36 | end 37 | 38 | fclose(fid); 39 | 40 | %% 41 | clearvars -except image 42 | -------------------------------------------------------------------------------- /extract/pinnacle_extractX/roiConvert_pinnacle_extractX.m: -------------------------------------------------------------------------------- 1 | function [extractWrite] = roiConvert_pinnacle_extractX(extractWrite,extractRead,entry) 2 | %% 3 | %Look for the converted roi file 4 | files = dir(extractWrite.project_patient); 5 | 6 | found = false; 7 | for i = 1:numel(files) 8 | if strcmpi(files(i).name,extractWrite.roi_file) 9 | found = true; 10 | break 11 | end 12 | end 13 | 14 | %If not found, then convert it... 15 | if ~found 16 | disp(['TREX-RT>> Entry ',num2str(entry),': Reading ROI data...']) 17 | 18 | roi = roi2Mask_pinnacle_extractX(extractWrite,entry); 19 | 20 | extractWrite.convertROI = true; 21 | extractWrite.convertROI_datestr = datestr(now,'yyyymmddHHMMSS'); 22 | 23 | save(fullfile(extractWrite.project_patient,extractWrite.roi_file),'-struct','roi') 24 | save(fullfile(extractWrite.project_patient,extractWrite.roi_file),'-struct','extractWrite','-append') 25 | 26 | disp(['TREX-RT>> Entry ',num2str(entry),': ROI mask saved ',extractWrite.roi_file]) 27 | else 28 | extractWrite.convertROI = true; 29 | extractWrite.convertROI_datestr = extractRead.convertROI_datestr; 30 | end 31 | 32 | %% 33 | clearvars -except extractWrite 34 | -------------------------------------------------------------------------------- /extract/pinnacle_extractX/validate_pinnacle_extractX.m: -------------------------------------------------------------------------------- 1 | function [extractWrite] = validate_pinnacle_extractX(extractWrite,entry) 2 | %% 3 | %Try to connect to server if it is remote pinnacle 4 | if extractWrite.remote 5 | try 6 | extractWrite.ftp = ftp(extractWrite.server_name,extractWrite.server_user,extractWrite.server_pass); 7 | catch err 8 | disp(['TREX-RT>> Entry ',num2str(entry),': ','Server connection could not be established!']); 9 | return 10 | end 11 | end 12 | 13 | %Try to find patient directory 14 | if extractWrite.remote 15 | try 16 | cd(extractWrite.ftp,extractWrite.patient_path); 17 | catch err 18 | disp(['TREX-RT>> Entry ',num2str(entry),': ','Associated patient directory not found!']); 19 | return 20 | end 21 | else 22 | if exist(extractWrite.patient_path,'dir') ~= 7 23 | disp(['TREX-RT>> Entry ',num2str(entry),': ','Associated patient directory not found!']); 24 | return 25 | end 26 | end 27 | 28 | %Make sure that the plan path exists 29 | if extractWrite.remote 30 | try 31 | cd(extractWrite.ftp,extractWrite.plan_path); 32 | catch err 33 | disp(['TREX-RT>> Entry ',num2str(entry),': ','Associated plan not found!']); 34 | return 35 | end 36 | else 37 | if exist(extractWrite.plan_path,'dir') ~= 7 38 | disp(['TREX-RT>> Entry ',num2str(entry),': ','Associated plan not found!']); 39 | return 40 | end 41 | end 42 | 43 | extractWrite.validated = true; 44 | 45 | disp(['TREX-RT>> Entry ',num2str(entry),': ','Validated!']); 46 | 47 | %% 48 | clearvars -except extractWrite 49 | -------------------------------------------------------------------------------- /extract/read_extractX.m: -------------------------------------------------------------------------------- 1 | function [extractRead] = read_extractX(project_path,varargin) 2 | 3 | disp_flag = true; 4 | 5 | if nargin > 1 6 | disp_flag = varargin{1}; 7 | if ~islogical(disp_flag) 8 | error('I should really validate attributes...') 9 | end 10 | end 11 | 12 | %% 13 | extractRead = []; 14 | 15 | try 16 | files = dir(fullfile(project_path,'Log')); 17 | 18 | %Find the most current _extractX file 19 | date = 0; 20 | for i = 1:numel(files) 21 | if ~isempty(regexpi(files(i).name,'_extractX.mat$')) 22 | filedate = str2double(files(i).name(1:14)); 23 | 24 | if filedate > date 25 | date = filedate; 26 | end 27 | end 28 | end 29 | 30 | extractRead = load(fullfile(project_path,'Log',[num2str(date),'_extractX.mat'])); 31 | 32 | if disp_flag 33 | disp(['TREX-RT>> Importing extractX data: ',num2str(date),'_extractX.mat']); 34 | end 35 | 36 | catch err 37 | 38 | end 39 | 40 | %% 41 | clearvars -except extractRead 42 | -------------------------------------------------------------------------------- /helper/create_configX.m: -------------------------------------------------------------------------------- 1 | function create_configX(mainDir) 2 | 3 | config = cell(0); 4 | config{1,1} = 'notifier-mail = '; 5 | config{2,1} = 'notifier-password = '; 6 | config{3,1} = 'pinnacle-server = '; 7 | config{4,1} = 'default-project = '; 8 | config{5,1} = 'default-directory = '; 9 | 10 | dlmcellX(fullfile(mainDir,'config.trex'),config) 11 | -------------------------------------------------------------------------------- /helper/filter_list.trex: -------------------------------------------------------------------------------- 1 | Parameter Name,Matlab Name,Full Name,Latex Name 2 | Filter,Gradient2D_sobel,2D Sobel Gradient Filter,2D Sobel Gradient Filter 3 | Filter,Gradient3D_Filter_sobel,3D Sobel Gradient Filter,3D Sobel Gradient Filter 4 | Filter,LoG_Filter_10_2,Laplacian of Gaussian Filter (Size=10; Sigma=2),Laplacian of Gaussian Filter (Size=10; Sigma=2) 5 | Filter,LoG_Filter_12_2p5,Laplacian of Gaussian Filter (Size=12; Sigma=2.5),Laplacian of Gaussian Filter (Size=12; Sigma=2.5) 6 | Filter,LoG_Filter_4_1,Laplacian of Gaussian Filter (Size=4; Sigma=1),Laplacian of Gaussian Filter (Size=4; Sigma=1) 7 | Filter,LoG_Filter_6_1p5,Laplacian of Gaussian Filter (Size=6; Sigma=1.5),Laplacian of Gaussian Filter (Size=6; Sigma=1.5) 8 | Filter,LoG_Filter_8_1p8,Laplacian of Gaussian Filter (Size=8; Sigma=1.8),Laplacian of Gaussian Filter (Size=8; Sigma=1.8) 9 | Filter,Local_Entropy_Filter_3,Local Entropy Filter (NHood=3),Local Entropy Filter (NHood=3) 10 | Filter,Local_Range_Filter_3,Local Range Filter (NHood=3),Local Range Filter (NHood=3) 11 | Filter,Local_STD_Filter_3,Local Standard Deviation Filter (NHood=3),Local Standard Deviation Filter (NHood=3) 12 | Filter,None,None,None 13 | Filter,Threshold_1000,Threshold 0 HU,Threshold 0 HU 14 | Filter,Threshold_250,Threshold -750 HU,Threshold -750 HU 15 | Filter,Threshold_500,Threshold -500 HU,Threshold -500 HU 16 | Filter,Threshold_750,Threshold -250 HU,Threshold -250 HU -------------------------------------------------------------------------------- /helper/getDate_logX.m: -------------------------------------------------------------------------------- 1 | function [date] = getDate_logX(project_path,module) 2 | % Returns 0 if file not found 3 | 4 | date = 0; 5 | files = dir(fullfile(project_path,'Log')); 6 | 7 | % Look for a file matching the module 8 | good = 0; 9 | for i = 1:numel(files) 10 | if ~isempty(regexpi(files(i).name,['(\w*)_',module,'(\w*)X.mat'])) 11 | good = 1; 12 | break 13 | end 14 | end 15 | 16 | if ~good 17 | return 18 | end 19 | 20 | % Find the most recent one to read in 21 | for i = 1:numel(files) 22 | if ~isempty(regexpi(files(i).name,['(\w*)_',module,'(\w*)X.mat'])) 23 | % filedate = str2double(strrep(files(i).name,['_',module,'X.mat'],'')); 24 | filedate = str2double(files(i).name(1:14)); 25 | 26 | if filedate > date 27 | date = filedate; 28 | end 29 | end 30 | end 31 | 32 | %% 33 | clearvars -except date 34 | -------------------------------------------------------------------------------- /helper/imresize3DX.m: -------------------------------------------------------------------------------- 1 | function [B,RB] = imresize3DX(A,pixdim,tsize,Interp) 2 | % This function resizes a 3D image volume to new dimensions 3 | % [B,RB] = imresize3DX(A,pixdim,tsize,Interp); 4 | % 5 | % inputs 6 | % A: The input image volume 7 | % pixdim: the pixel dimensions of the input volume [x,y,z] 8 | % tsize: new dimensions or the output image volume [r,c,z] 9 | % Interp: Type of interpolation ('nearest', 'linear', or 'cubic') 10 | % npad: Boundary condition ('replicate', 'symmetric', 'circular', 'fill', or 'bound') 11 | % 12 | % outputs, 13 | % B: The resized image volume 14 | % 15 | % SPK 06/06/2016 16 | 17 | % %% Shift all of the pixel values in the original image if necessary for nan setting 18 | % ind_nan = isnan(A); 19 | % 20 | % % What does the shifting of nans do here? 21 | % A(ind_nan) = nanmedian(A(:)); %set all nan to zero 22 | 23 | %% Extrapolate beyond the boundaries and available array points using nearest neighbor 24 | [x,y,z] = meshgrid(1:size(A,2),1:size(A,1),1:size(A,3)); 25 | x = x(:); 26 | y = y(:); 27 | z = z(:); 28 | 29 | v = A(:); 30 | 31 | ind = ~isnan(v); 32 | 33 | F = scatteredInterpolant(x(ind),y(ind),z(ind),v(ind),'linear','linear'); 34 | vq = F(x(~ind),y(~ind),z(~ind)); 35 | 36 | A(~ind) = vq; 37 | 38 | clear x 39 | clear y 40 | clear z 41 | clear v 42 | clear ind 43 | clear F 44 | clear vq 45 | 46 | %% Do the magic here 47 | % scale = tsize./size(A); 48 | scale = ones(ndims(A),1); 49 | tform = affine3d([scale(2) 0 0 0; 0 scale(1) 0 0; 0 0 scale(3) 0; 0 0 0 1]); 50 | 51 | RA = imref3d(size(A),pixdim(1),pixdim(2),pixdim(3)); %x,y,z pixel dimensions 52 | 53 | Rout = imref3d(tsize,size(A,2)/tsize(2)*pixdim(1),... 54 | size(A,1)/tsize(1)*pixdim(2),... 55 | size(A,3)/tsize(3)*pixdim(3)); %x,y,z pixel dimensions 56 | 57 | [B,RB] = imwarp(A,RA,tform,Interp,'FillValues',0,'OutputView',Rout); 58 | 59 | %% If the size doesn't match, we have a problem... 60 | if sum(size(B) ~= tsize) > 0 61 | error('here') 62 | end 63 | 64 | %% 65 | clearvars -except B RB 66 | 67 | -------------------------------------------------------------------------------- /helper/readcsvX.m: -------------------------------------------------------------------------------- 1 | function [output] = readcsvX(filename) 2 | %% 3 | fid = fopen(filename); % Open the file 4 | 5 | lineIndex = 1; % Index of cell to place the next line in 6 | nextLine = fgetl(fid); % Read the first line from the file 7 | while ~isequal(nextLine,-1) % Loop while not at the end of the file 8 | lineArray{lineIndex} = nextLine; % Add the line to the cell array 9 | lineIndex = lineIndex+1; % Increment the line index 10 | nextLine = fgetl(fid); % Read the next line from the file 11 | end 12 | fclose(fid); 13 | 14 | for i = 1:lineIndex-1 % Loop over lines 15 | lineData = textscan(lineArray{i},'%s','Delimiter',','); 16 | lineData = lineData{1}; 17 | % Remove cell encapsulation 18 | if strcmp(lineArray{i}(end),',') % Account for when the line 19 | lineData{end+1} = ''; % ends with a delimiter 20 | end 21 | output(i,1:numel(lineData)) = lineData; % Overwrite line data 22 | end 23 | 24 | %% 25 | clearvars -except output 26 | -------------------------------------------------------------------------------- /helper/sc/autumn.m: -------------------------------------------------------------------------------- 1 | %AUTUMN Red-yellow colormap 2 | % 3 | % Examples: 4 | % map = autumn; 5 | % map = autumn(len); 6 | % B = autumn(A); 7 | % B = autumn(A, lims); 8 | % 9 | % Similar to MATLAB's autumn function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)x3 colormap table. 25 | % B - size(A)x3 truecolor array. 26 | 27 | % Copyright: Oliver Woodford, 2009 28 | 29 | function map = autumn(varargin) 30 | map = [1 0 0; 1 1 0]; 31 | map = colormap_helper(map, varargin{:}); 32 | -------------------------------------------------------------------------------- /helper/sc/bled.m: -------------------------------------------------------------------------------- 1 | %BLED Black to red variation of the hsv colormap 2 | % 3 | % Examples: 4 | % map = bled; 5 | % map = bled(len); 6 | % B = bled(A); 7 | % B = bled(A, lims); 8 | % 9 | % A variation of MATLAB's hsv colormap, which starts in black and gradually 10 | % increases in color saturation. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)x3 colormap table. 25 | % B - size(A)x3 truecolor array. 26 | 27 | % Copyright: Oliver Woodford, 2009 28 | 29 | function map = bled(varargin) 30 | map = [0 0 0; 1 1 0; 0 2 0; 0 3 3; 0 0 4; 5 0 5; 6 0 0] / 6; 31 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/bone.m: -------------------------------------------------------------------------------- 1 | %BONE Black-blue-white colormap 2 | % 3 | % Examples: 4 | % map = bone; 5 | % map = bone(len); 6 | % B = bone(A); 7 | % B = bone(A, lims); 8 | % 9 | % Similar to MATLAB's bone function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)xJ colormap table. J = 3, except in the concise case, when 25 | % J = 4, map(1:end-1,4) giving the relative sizes of the 26 | % inter-color bins. 27 | % B - size(A)x3 truecolor array. 28 | 29 | % Copyright: Oliver Woodford, 2009 30 | 31 | function map = bone(varargin) 32 | map = [0 0 0 3; 21 21 29 3; 42 50 50 2; 64 64 64 1]/64; 33 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/bright.m: -------------------------------------------------------------------------------- 1 | %BRIGHT Black-bright-white colormap 2 | % 3 | % Examples: 4 | % map = bright 5 | % map = bright(len) 6 | % B = bright(A) 7 | % B = bright(A, lims) 8 | % 9 | % A black to white colormap with several distinct shades of bright color. 10 | % This colormap converts linearly to grayscale when printed in black & 11 | % white. 12 | % 13 | % The function can additionally be used to convert a real-valued array into 14 | % a truecolor array using the colormap. 15 | % 16 | % IN: 17 | % len - Scalar length of the output colormap. If len == Inf the concise 18 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 19 | % A - Non-scalar numeric array of real values to be converted into 20 | % truecolor. 21 | % lims - 1x2 array of saturation limits to be used on A. Default: 22 | % [min(A(:)) max(A(:))]. 23 | % 24 | % OUT: 25 | % map - (len)x3 colormap table. 26 | % B - size(A)x3 truecolor array. 27 | 28 | % Copyright: Oliver Woodford, 2009 29 | 30 | function map = bright(varargin) 31 | map = [0 0 0; 0.3071 0.0107 0.3925; 0.007 0.289 1; 1 0.0832 0.7084; 32 | 1 0.4447 0.1001; 0.5776 0.8360 0.4458; 0.9035 1 0; 1 1 1]; 33 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/cold.m: -------------------------------------------------------------------------------- 1 | %COLD Black-blue-cyan-white colormap 2 | % 3 | % Examples: 4 | % map = cold; 5 | % map = cold(len); 6 | % B = cold(A); 7 | % B = cold(A, lims); 8 | % 9 | % A black to white colormap through cold shades. 10 | % 11 | % The function can additionally be used to convert a real-valued array into 12 | % a truecolor array using the colormap. 13 | % 14 | % IN: 15 | % len - Scalar length of the output colormap. If len == Inf the concise 16 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 17 | % A - Non-scalar numeric array of real values to be converted into 18 | % truecolor. 19 | % lims - 1x2 array of saturation limits to be used on A. Default: 20 | % [min(A(:)) max(A(:))]. 21 | % 22 | % OUT: 23 | % map - (len)xJ colormap table. J = 3, except in the concise case, when 24 | % J = 4, map(1:end-1,4) giving the relative sizes of the 25 | % inter-color bins. 26 | % B - size(A)x3 truecolor array. 27 | 28 | % Copyright: Oliver Woodford, 2009 29 | % Based on a colormap by Joseph Kirk, FEX ID: 23865 30 | 31 | function map = cold(varargin) 32 | map = [0 0 0; 0 0 1; 0 1 1; 1 1 1]; 33 | map = colormap_helper(map, varargin{:}); 34 | -------------------------------------------------------------------------------- /helper/sc/cool.m: -------------------------------------------------------------------------------- 1 | %COOL Cyan-magenta colormap 2 | % 3 | % Examples: 4 | % map = cool; 5 | % map = cool(len); 6 | % B = cool(A); 7 | % B = cool(A, lims); 8 | % 9 | % Similar to MATLAB's cool function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)x3 colormap table. 25 | % B - size(A)x3 truecolor array. 26 | 27 | % Copyright: Oliver Woodford, 2009 28 | 29 | function map = cool(varargin) 30 | map = [0 1 1; 1 0 1]; 31 | map = colormap_helper(map, varargin{:}); 32 | -------------------------------------------------------------------------------- /helper/sc/copper.m: -------------------------------------------------------------------------------- 1 | %COPPER Black-copper colormap 2 | % 3 | % Examples: 4 | % map = copper; 5 | % map = copper(len); 6 | % B = copper(A); 7 | % B = copper(A, lims); 8 | % 9 | % Similar to MATLAB's copper function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)x3 colormap table. 25 | % B - size(A)x3 truecolor array. 26 | 27 | % Copyright: Oliver Woodford, 2009 28 | 29 | function map = copper(varargin) 30 | map = [0 0 0 8; 1 0.625 0.398 2; 1 0.7812 0.4975 0]; 31 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/copper2.m: -------------------------------------------------------------------------------- 1 | %COPPER2 Black-copper-white colormap 2 | % 3 | % Examples: 4 | % map = copper2; 5 | % map = copper2(len); 6 | % B = copper2(A); 7 | % B = copper2(A, lims); 8 | % 9 | % A variation of MATLAB's copper colormap, which continues on to white. 10 | % This colormap converts linearly to grayscale when printed in black & 11 | % white. 12 | % 13 | % The function can additionally be used to convert a real-valued array into 14 | % a truecolor array using the colormap. 15 | % 16 | % IN: 17 | % len - Scalar length of the output colormap. If len == Inf the concise 18 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 19 | % A - Non-scalar numeric array of real values to be converted into 20 | % truecolor. 21 | % lims - 1x2 array of saturation limits to be used on A. Default: 22 | % [min(A(:)) max(A(:))]. 23 | % 24 | % OUT: 25 | % map - (len)x3 colormap table. 26 | % B - size(A)x3 truecolor array. 27 | 28 | % Copyright: Oliver Woodford, 2009 29 | 30 | function map = copper2(varargin) 31 | map = [0 0 0; 0.2651 0.2426 0.2485; 0.666 0.4399 0.3738; 0.8118 0.7590 0.5417; 1 1 1]; 32 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/dusk.m: -------------------------------------------------------------------------------- 1 | %DUSK Black-blue-green-gray-red-yellow-white colormap 2 | % 3 | % Examples: 4 | % map = dusk; 5 | % map = dusk(len); 6 | % B = dusk(A); 7 | % B = dusk(A, lims); 8 | % 9 | % A black to white colormap with several distinct pastel shades reminiscent 10 | % of colors at dusk. This colormap converts linearly to grayscale when 11 | % printed in black & white. 12 | % 13 | % The function can additionally be used to convert a real-valued array into 14 | % a truecolor array using the colormap. 15 | % 16 | % IN: 17 | % len - Scalar length of the output colormap. If len == Inf the concise 18 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 19 | % A - Non-scalar numeric array of real values to be converted into 20 | % truecolor. 21 | % lims - 1x2 array of saturation limits to be used on A. Default: 22 | % [min(A(:)) max(A(:))]. 23 | % 24 | % OUT: 25 | % map - (len)xJ colormap table. J = 3, except in the concise case, when 26 | % J = 4, map(1:end-1,4) giving the relative sizes of the 27 | % inter-color bins. 28 | % B - size(A)x3 truecolor array. 29 | 30 | % Copyright: Oliver Woodford, 2009 31 | 32 | function map = dusk(varargin) 33 | map = [0 0 0 114; 0 0 0.5 587; 0 0.5 0.5 299; 0.5 0.5 0.5 299; 1 0.5 0.5 587; 1 1 0.5 114; 1 1 1 0]; 34 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/earth.m: -------------------------------------------------------------------------------- 1 | %EARTH Black-green-white colormap 2 | % 3 | % Examples: 4 | % map = earth; 5 | % map = earth(len); 6 | % B = earth(A); 7 | % B = earth(A, lims); 8 | % 9 | % A black to white colormap with several distinct shades, most of which 10 | % have a green or brown tint. This colormap converts linearly to grayscale 11 | % when printed in black & white. 12 | % 13 | % The function can additionally be used to convert a real-valued array into 14 | % a truecolor array using the colormap. 15 | % 16 | % IN: 17 | % len - Scalar length of the output colormap. If len == Inf the concise 18 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 19 | % A - Non-scalar numeric array of real values to be converted into 20 | % truecolor. 21 | % lims - 1x2 array of saturation limits to be used on A. Default: 22 | % [min(A(:)) max(A(:))]. 23 | % 24 | % OUT: 25 | % map - (len)x3 colormap table. 26 | % B - size(A)x3 truecolor array. 27 | 28 | % Copyright: Oliver Woodford, 2009 29 | 30 | function map = earth(varargin) 31 | map = [0 0 0; 0 0.1104 0.0583; 0.1661 0.1540 0.0248; 0.1085 0.2848 0.1286;... 32 | 0.2643 0.3339 0.0939; 0.2653 0.4381 0.1808; 0.3178 0.5053 0.3239;... 33 | 0.4858 0.5380 0.3413; 0.6005 0.5748 0.4776; 0.5698 0.6803 0.6415;... 34 | 0.5639 0.7929 0.7040; 0.6700 0.8626 0.6931; 0.8552 0.8967 0.6585;... 35 | 1 0.9210 0.7803; 1 1 1]; 36 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/gray.m: -------------------------------------------------------------------------------- 1 | %GRAY Black-white colormap 2 | % 3 | % Examples: 4 | % map = gray; 5 | % map = gray(len); 6 | % B = gray(A); 7 | % B = gray(A, lims); 8 | % 9 | % Similar to MATLAB's gray function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)xJ colormap table. J = 3, except in the concise case, when 25 | % J = 4, map(1:end-1,4) giving the relative sizes of the 26 | % inter-color bins. 27 | % B - size(A)x3 truecolor array. 28 | 29 | % Copyright: Oliver Woodford, 2009 30 | 31 | function map = gray(varargin) 32 | map = [0 0 0; 1 1 1]; 33 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/hicontrast.m: -------------------------------------------------------------------------------- 1 | %HICONTRAST Black-blue-red-magenta-green-cyan-yellow-white colormap 2 | % 3 | % Examples: 4 | % map = hicontrast; 5 | % map = hicontrast(len); 6 | % B = hicontrast(A); 7 | % B = hicontrast(A, lims); 8 | % 9 | % A colormap designed to maximize the range of colors used in order to 10 | % improve contrast between intensity levels, while converting linearly to 11 | % grayscale, such that black & white prints come out nicely. 12 | % 13 | % The function can additionally be used to convert a real valued array into 14 | % a truecolor array using the colormap. 15 | % 16 | % IN: 17 | % len - Scalar length of the output colormap. If len == Inf the concise 18 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 19 | % A - Non-scalar numeric array of real values to be converted into 20 | % truecolor. 21 | % lims - 1x2 array of saturation limits to be used on A. Default: 22 | % [min(A(:)) max(A(:))]. 23 | % 24 | % OUT: 25 | % map - (len)xJ colormap table. J = 3, except in the concise case, when 26 | % J = 4, map(1:end-1,4) giving the relative sizes of the 27 | % inter-color bins. 28 | % B - size(A)x3 truecolor array. 29 | 30 | % Copyright: Oliver Woodford, 2009 31 | 32 | function map = hicontrast(varargin) 33 | map = [0 0 0 114; 0 0 1 185; 1 0 0 114; 1 0 1 174;... 34 | 0 1 0 114; 0 1 1 185; 1 1 0 114; 1 1 1 0]; 35 | map = colormap_helper(map, varargin{:}); 36 | -------------------------------------------------------------------------------- /helper/sc/hot.m: -------------------------------------------------------------------------------- 1 | %HOT Black-red-yellow-white colormap 2 | % 3 | % Examples: 4 | % map = hot; 5 | % map = hot(len); 6 | % B = hot(A); 7 | % B = hot(A, lims); 8 | % 9 | % Similar to MATLAB's hot function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)xJ colormap table. J = 3, except in the concise case, when 25 | % J = 4, map(1:end-1,4) giving the relative sizes of the 26 | % inter-color bins. 27 | % B - size(A)x3 truecolor array. 28 | 29 | % Copyright: Oliver Woodford, 2009 30 | 31 | function map = hot(varargin) 32 | map = [0 0 0 3; 1 0 0 3; 1 1 0 2; 1 1 1 0]; 33 | map = colormap_helper(map, varargin{:}); 34 | -------------------------------------------------------------------------------- /helper/sc/hsv.m: -------------------------------------------------------------------------------- 1 | %HSV Red-yellow-green-cyan-blue-magenta-red colormap 2 | % 3 | % Examples: 4 | % map = hsv; 5 | % map = hsv(len); 6 | % B = hsv(A); 7 | % B = hsv(A, lims); 8 | % 9 | % Similar to MATLAB's hsv function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)xJ colormap table. J = 3, except in the concise case, when 25 | % J = 4, map(1:end-1,4) giving the relative sizes of the 26 | % inter-color bins. 27 | % B - size(A)x3 truecolor array. 28 | 29 | % Copyright: Oliver Woodford, 2009 30 | 31 | function map = hsv(varargin) 32 | map = [1 0 0; 1 1 0; 0 1 0; 0 1 1; 0 0 1; 1 0 1; 1 0 0]; 33 | map = colormap_helper(map, varargin{:}); 34 | -------------------------------------------------------------------------------- /helper/sc/hsv2.m: -------------------------------------------------------------------------------- 1 | %HSV2 Black to red variation of the hsv colormap 2 | % 3 | % Examples: 4 | % map = hsv2; 5 | % map = hsv2(len); 6 | % B = hsv2(A); 7 | % B = hsv2(A, lims); 8 | % 9 | % A variation of MATLAB's hsv colormap, which starts in black. 10 | % 11 | % The function can additionally be used to convert a real-valued array into 12 | % a truecolor array using the colormap. 13 | % 14 | % IN: 15 | % len - Scalar length of the output colormap. If len == Inf the concise 16 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 17 | % A - Non-scalar numeric array of real values to be converted into 18 | % truecolor. 19 | % lims - 1x2 array of saturation limits to be used on A. Default: 20 | % [min(A(:)) max(A(:))]. 21 | % 22 | % OUT: 23 | % map - (len)x3 colormap table. 24 | % B - size(A)x3 truecolor array. 25 | 26 | % Copyright: Oliver Woodford, 2009 27 | 28 | function map = hsv2(varargin) 29 | map = [0 0 0; 0.5 0 0.5; 0 0 0.9; 0 1 1; 0 1 0; 1 1 0; 1 0 0]; 30 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/imsc.m: -------------------------------------------------------------------------------- 1 | %IMSC Wrapper function to SC which replicates display behaviour of IMAGESC 2 | % 3 | % Examples: 4 | % imsc(I, varargin) 5 | % imsc(x, y, I, varargin) 6 | % h = imsc(...) 7 | % 8 | % IN: 9 | % x - 1xJ vector of x-axis bounds. If x(1) > x(2) the image is flipped 10 | % left-right. If J > 2 then only the first and last values are used. 11 | % Default: [1 size(I, 2)]. 12 | % y - 1xK vector of y-axis bounds. If y(1) > y(2) the image is flipped 13 | % up-down. If K > 2 then only the first and last values are used. 14 | % Default: [1 size(I, 1)]. 15 | % I - MxNxC input image. 16 | % varargin - Extra input parameters passed to SC. See SC's help for more 17 | % information. 18 | % 19 | % OUT: 20 | % h - Handle of the image graphics object generated. 21 | % 22 | % See also IMAGESC, SC. 23 | 24 | % Copyright: Oliver Woodford, 2010 25 | 26 | function h = imsc(varargin) 27 | 28 | % Check for x, y as first two inputs 29 | if nargin > 2 && isvector(varargin{1}) && numel(varargin{1}) > 1 && isvector(varargin{2}) && numel(varargin{2}) > 1 30 | % Render 31 | [I, clim, map] = sc(varargin{3:end}); 32 | % Display 33 | h = image(varargin{1}([1 end]), varargin{2}([1 end]), I); 34 | else 35 | % Render 36 | [I, clim, map] = sc(varargin{:}); 37 | % Display 38 | h = image(I); 39 | end 40 | % Fix up colormap, if there is one 41 | if ~isempty(clim) 42 | set(h, 'CDataMapping', 'scaled'); 43 | ha = get(h, 'Parent'); 44 | set(ha, 'CLim', clim); 45 | set(get(ha, 'Parent'), 'Colormap', map); 46 | end 47 | % Don't display the handle if not requested 48 | if nargout < 1 49 | clear h 50 | end -------------------------------------------------------------------------------- /helper/sc/jet.m: -------------------------------------------------------------------------------- 1 | %JET Variant of HSV colormap 2 | % 3 | % Examples: 4 | % map = jet; 5 | % map = jet(len); 6 | % B = jet(A); 7 | % B = jet(A, lims); 8 | % 9 | % Similar to MATLAB's jet function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)xJ colormap table. J = 3, except in the concise case, when 25 | % J = 4, map(1:end-1,4) giving the relative sizes of the 26 | % inter-color bins. 27 | % B - size(A)x3 truecolor array. 28 | 29 | % Copyright: Oliver Woodford, 2009 30 | 31 | function map = jet(varargin) 32 | map = [0 0 0.5 1; 0 0 1 2; 0 1 1 2; 1 1 0 2; 1 0 0 1; 0.5 0 0 0]; 33 | map = colormap_helper(map, varargin{:}); 34 | -------------------------------------------------------------------------------- /helper/sc/pastel.m: -------------------------------------------------------------------------------- 1 | %PASTEL Black-pastel-white colormap 2 | % 3 | % Examples: 4 | % map = pastel; 5 | % map = pastel(len); 6 | % B = pastel(A); 7 | % B = pastel(A, lims); 8 | % 9 | % A black to white colormap with several distinct pastel shades. This 10 | % colormap converts linearly to grayscale when printed in black & white. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)x3 colormap table. 25 | % B - size(A)x3 truecolor array. 26 | 27 | % Copyright: Oliver Woodford, 2009 28 | 29 | function map = pastel(varargin) 30 | map = [0 0 0; 0.4709 0 0.018; 0 0.3557 0.6747; 0.8422 0.1356 0.8525; 31 | 0.4688 0.6753 0.3057; 1 0.6893 0.0934; 0.9035 1 0; 1 1 1]; 32 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/pink.m: -------------------------------------------------------------------------------- 1 | %PINK Black-pink-white colormap 2 | % 3 | % Examples: 4 | % map = pink 5 | % map = pink(len) 6 | % B = pink(A) 7 | % B = pink(A, lims) 8 | % 9 | % Similar to MATLAB's pink colormap, but the function can additionally be 10 | % used to convert a real-valued array into a truecolor array using the 11 | % colormap. 12 | % 13 | % IN: 14 | % len - Scalar length of the output colormap. If len == Inf the concise 15 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 16 | % A - Non-scalar numeric array of real values to be converted into 17 | % truecolor. 18 | % lims - 1x2 array of saturation limits to be used on A. Default: 19 | % [min(A(:)) max(A(:))]. 20 | % 21 | % OUT: 22 | % map - (len)x3 colormap table. 23 | % B - size(A)x3 truecolor array. 24 | 25 | % Copyright: Oliver Woodford, 2009 26 | 27 | function map = pink(len, varargin) 28 | if nargin < 1 29 | len = size(get(gcf, 'Colormap'), 1); 30 | end 31 | if isscalar(len) 32 | map = reshape(pink(1:len, [1 len]), [], 3); 33 | return 34 | end 35 | map = rescale(len(:), varargin{:}); 36 | J = map * (2 / 3); 37 | map = [map, map-1/3, map-2/3]; 38 | map = max(min(map, 1/3), 0); 39 | map = map + J(:,[1 1 1]); 40 | clear J 41 | map = sqrt(map); 42 | map = reshape(map, [size(len) 3]); 43 | -------------------------------------------------------------------------------- /helper/sc/pink2.m: -------------------------------------------------------------------------------- 1 | %PINK2 Black-pink-white colormap 2 | % 3 | % Examples: 4 | % map = pink2; 5 | % map = pink2(len); 6 | % B = pink2(A); 7 | % B = pink2(A, lims); 8 | % 9 | % A black to white colormap with several distinct shades, most of which 10 | % have a pink tint. This colormap converts linearly to grayscale when 11 | % printed in black & white. 12 | % 13 | % The function can additionally be used to convert a real-valued array into 14 | % a truecolor array using the colormap. 15 | % 16 | % IN: 17 | % len - Scalar length of the output colormap. If len == Inf the concise 18 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 19 | % A - Non-scalar numeric array of real values to be converted into 20 | % truecolor. 21 | % lims - 1x2 array of saturation limits to be used on A. Default: 22 | % [min(A(:)) max(A(:))]. 23 | % 24 | % OUT: 25 | % map - (len)x3 colormap table. 26 | % B - size(A)x3 truecolor array. 27 | 28 | % Copyright: Oliver Woodford, 2009 29 | 30 | function map = pink2(varargin) 31 | map = [0 0 0; 0.0455 0.0635 0.1801; 0.2425 0.0873 0.1677;... 32 | 0.2089 0.2092 0.2546; 0.3111 0.2841 0.2274; 0.4785 0.3137 0.2624;... 33 | 0.5781 0.3580 0.3997; 0.5778 0.4510 0.5483; 0.5650 0.5682 0.6047;... 34 | 0.6803 0.6375 0.5722; 0.8454 0.6725 0.5855; 0.9801 0.7032 0.7007;... 35 | 1 0.7777 0.8915; 0.9645 0.8964 1; 1 1 1]; 36 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/private/colormap_helper.m: -------------------------------------------------------------------------------- 1 | function map = colormap_helper(map, len, lims) 2 | %COLORMAP_HELPER Helper function for colormaps 3 | % 4 | % Examples: 5 | % map = colormap_helper(map); 6 | % map = colormap_helper(map, len); 7 | % B = colormap_helper(map, A); 8 | % B = colormap_helper(map, A, lims); 9 | % 10 | % Given a concise colormap table (i.e. one that contains all the 11 | % information required to create a full colormap, without any redundancy), 12 | % this function can return a colormap of the desired length, or convert a 13 | % real-valued array into truecolor array using the colormap. 14 | % 15 | % IN: 16 | % map - KxJ colormap table. J = 3, except in the non-linear case, when 17 | % J = 4, map(1:end-1,4) giving the relative sizes of the 18 | % inter-color bins. 19 | % len - Scalar length of the output colormap. If len == Inf the concise 20 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 21 | % A - Non-scalar numeric array of real values to be converted into 22 | % truecolor. 23 | % lims - 1x2 array of saturation limits to be used on A. Default: 24 | % [min(A(:)) max(A(:))]. 25 | % 26 | % OUT: 27 | % map - (len)xJ colormap table. J = 3, except in the concise case, when 28 | % J = 4, map(1:end-1,4) giving the relative sizes of the 29 | % inter-color bins. 30 | % B - size(A)x3 truecolor array. 31 | 32 | % $Id: colormap_helper.m,v 1.4 2009/04/13 12:16:22 ojw Exp $ 33 | % Copyright: Oliver Woodford, 2009 34 | 35 | if nargin < 2 36 | len = size(get(gcf, 'Colormap'), 1); 37 | end 38 | if isscalar(len) 39 | if len == Inf 40 | % Return the concise colormap table 41 | return 42 | end 43 | len = 1:len; 44 | sz = numel(len); 45 | lims = [1 sz]; 46 | else 47 | sz = size(len); 48 | if nargin < 3 49 | lims = []; 50 | end 51 | end 52 | map = reshape(real2rgb(len(:), map, lims), [sz 3]); -------------------------------------------------------------------------------- /helper/sc/private/rescale.m: -------------------------------------------------------------------------------- 1 | function [B lims] = rescale(A, lims, out_lims) 2 | %RESCALE Linearly rescale values in an array 3 | % 4 | % Examples: 5 | % B = rescale(A) 6 | % B = rescale(A, lims) 7 | % B = rescale(A, lims, out_lims) 8 | % [B lims] = rescale(A) 9 | % 10 | % Linearly rescales values in an array, saturating values outside limits. 11 | % 12 | % IN: 13 | % A - Input array of any size and class. 14 | % lims - 1x2 array of saturation limits to be used on A. Default: 15 | % [min(A(:)) max(A(:))]. 16 | % out_lims - 1x2 array of output limits the values in lims are to be 17 | % rescaled to. Default: [0 1]. 18 | % 19 | % OUT: 20 | % B - size(A) double array. 21 | % lims - 1x2 array of saturation limits used on A. Equal to the input 22 | % lims, if given. 23 | 24 | % Copyright: Oliver Woodford, 2009 - 2011 25 | 26 | % 14/01/11 Fixed a bug brought to my attention by Ming Wu (Many thanks!). 27 | 28 | if nargin < 3 29 | out_lims = [0 1]; 30 | end 31 | if nargin < 2 || isempty(lims) 32 | M = isfinite(A); 33 | if ~any(reshape(M, numel(M), 1)) 34 | % All NaNs, Infs or -Infs 35 | B = double(A > 0); 36 | lims = [0 1]; 37 | else 38 | lims = [min(A(M)) max(A(M))]; 39 | B = normalize(A, lims, out_lims); 40 | B = min(max(B, out_lims(1)), out_lims(2)); 41 | end 42 | clear M 43 | else 44 | B = normalize(A, lims, out_lims); 45 | B = min(max(B, out_lims(1)), out_lims(2)); 46 | end 47 | return 48 | 49 | function B = normalize(A, lims, out_lims) 50 | if lims(2) == lims(1) || out_lims(1) == out_lims(2) 51 | B = zeros(size(A)); 52 | else 53 | B = double(A); 54 | if lims(1) 55 | B = B - lims(1); 56 | end 57 | v = (out_lims(2) - out_lims(1)) / (lims(2) - lims(1)); 58 | if v ~= 1 59 | B = B * v; 60 | end 61 | end 62 | if out_lims(1) 63 | B = B + out_lims(1); 64 | end 65 | return -------------------------------------------------------------------------------- /helper/sc/sepia.m: -------------------------------------------------------------------------------- 1 | %SEPIA Black-brown-white colormap 2 | % 3 | % Examples: 4 | % map = sepia; 5 | % map = sepia(len); 6 | % B = sepia(A); 7 | % B = sepia(A, lims); 8 | % 9 | % A colormap designed to replicate the sepia tones of old photographs. 10 | % 11 | % The function can additionally be used to convert a real-valued array into 12 | % a truecolor array using the colormap. 13 | % 14 | % IN: 15 | % len - Scalar length of the output colormap. If len == Inf the concise 16 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 17 | % A - Non-scalar numeric array of real values to be converted into 18 | % truecolor. 19 | % lims - 1x2 array of saturation limits to be used on A. Default: 20 | % [min(A(:)) max(A(:))]. 21 | % 22 | % OUT: 23 | % map - (len)xJ colormap table. J = 3, except in the concise case, when 24 | % J = 4, map(1:end-1,4) giving the relative sizes of the 25 | % inter-color bins. 26 | % B - size(A)x3 truecolor array. 27 | 28 | % Copyright: Oliver Woodford, 2009 29 | 30 | function map = sepia(varargin) 31 | map = [0 0 0 5; 0.1 0.05 0 85; 1 0.9 0.8 10; 1 1 1 0]; 32 | map = colormap_helper(map, varargin{:}); 33 | -------------------------------------------------------------------------------- /helper/sc/spring.m: -------------------------------------------------------------------------------- 1 | %SPRING Magenta-yellow colormap 2 | % 3 | % Examples: 4 | % map = spring; 5 | % map = spring(len); 6 | % B = spring(A); 7 | % B = spring(A, lims); 8 | % 9 | % Similar to MATLAB's spring function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)x3 colormap table. 25 | % B - size(A)x3 truecolor array. 26 | 27 | % Copyright: Oliver Woodford, 2009 28 | 29 | function map = spring(varargin) 30 | map = [1 0 1; 1 1 0]; 31 | map = colormap_helper(map, varargin{:}); 32 | -------------------------------------------------------------------------------- /helper/sc/summer.m: -------------------------------------------------------------------------------- 1 | %SUMMER Green-yellow colormap 2 | % 3 | % Examples: 4 | % map = summer; 5 | % map = summer(len); 6 | % B = summer(A); 7 | % B = summer(A, lims); 8 | % 9 | % Similar to MATLAB's summer function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)x3 colormap table. 25 | % B - size(A)x3 truecolor array. 26 | 27 | % Copyright: Oliver Woodford, 2009 28 | 29 | function map = summer(varargin) 30 | map = [0 0.5 0.4; 1 1 0.4]; 31 | map = colormap_helper(map, varargin{:}); 32 | -------------------------------------------------------------------------------- /helper/sc/temp.m: -------------------------------------------------------------------------------- 1 | %TEMP Blue-pale-dark red colormap 2 | % 3 | % Examples: 4 | % map = temp 5 | % map = temp(len) 6 | % B = temp(A) 7 | % B = temp(A, lims) 8 | % 9 | % A colormap designed by Light & Bartlein for visualizing data such as 10 | % temperature, with good contrast for colorblind viewers. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)x3 colormap table. 25 | % B - size(A)x3 truecolor array. 26 | 27 | % Copyright: Oliver Woodford, 2009 28 | 29 | % Reference: 30 | % A. Light & P.J. Bartlein, "The End of the Rainbow? Color Schemes for 31 | % Improved Data Graphics", EOS Transactions of the American Geophysical 32 | % Union, Vol. 85, No. 40, 5 October 2004. 33 | % http://geography.uoregon.edu/datagraphics/EOS/index.htm 34 | 35 | function map = temp(varargin) 36 | map = [0.142 0 0.850; 0.097 0.112 0.970; 0.160 0.342 1;... 37 | 0.24 0.531 1; 0.34 0.692 1; 0.46 0.829 1;... 38 | 0.6 0.92 1; 0.74 0.978 1; 0.92 1 1; 1 1 0.92;... 39 | 1 0.948 0.74; 1 0.84 0.6; 1 0.676 0.46; 1 0.472 0.34;... 40 | 1 0.24 0.24; 0.97 0.155 0.21; 0.85 0.085 0.187;... 41 | 0.65 0 0.13]; 42 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/thermal.m: -------------------------------------------------------------------------------- 1 | %THERMAL Black-purple-red-yellow-white colormap 2 | % 3 | % Examples: 4 | % map = thermal; 5 | % map = thermal(len); 6 | % B = thermal(A); 7 | % B = thermal(A, lims); 8 | % 9 | % A colormap designed to replicate the tones of thermal images. 10 | % 11 | % The function can additionally be used to convert a real-valued array into 12 | % a truecolor array using the colormap. 13 | % 14 | % IN: 15 | % len - Scalar length of the output colormap. If len == Inf the concise 16 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 17 | % A - Non-scalar numeric array of real values to be converted into 18 | % truecolor. 19 | % lims - 1x2 array of saturation limits to be used on A. Default: 20 | % [min(A(:)) max(A(:))]. 21 | % 22 | % OUT: 23 | % map - (len)x3 colormap table. 24 | % B - size(A)x3 truecolor array. 25 | 26 | % Copyright: Oliver Woodford, 2009 27 | 28 | function map = thermal(varargin) 29 | map = [0 0 0; 0.3 0 0.7; 1 0.2 0; 1 1 0; 1 1 1]; 30 | map = colormap_helper(map, varargin{:}); 31 | -------------------------------------------------------------------------------- /helper/sc/whed.m: -------------------------------------------------------------------------------- 1 | %WHED White to red variation of the hsv colormap 2 | % 3 | % Examples: 4 | % map = whed; 5 | % map = whed(len); 6 | % B = whed(A); 7 | % B = whed(A, lims); 8 | % 9 | % A variation of MATLAB's hsv colormap, which starts in white and gradually 10 | % increases in color saturation. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)x3 colormap table. 25 | % B - size(A)x3 truecolor array. 26 | 27 | % Copyright: Oliver Woodford, 2010 28 | 29 | function map = whed(varargin) 30 | map = [6 6 6; 6 6 5; 4 6 4; 3 6 6; 2 2 6; 6 1 6; 6 0 0] / 6; 31 | map = colormap_helper(map, varargin{:}); -------------------------------------------------------------------------------- /helper/sc/winter.m: -------------------------------------------------------------------------------- 1 | %WINTER Blue-green colormap 2 | % 3 | % Examples: 4 | % map = winter; 5 | % map = winter(len); 6 | % B = winter(A); 7 | % B = winter(A, lims); 8 | % 9 | % Similar to MATLAB's winter function, but also able to return a concise 10 | % colormap table. 11 | % 12 | % The function can additionally be used to convert a real-valued array into 13 | % a truecolor array using the colormap. 14 | % 15 | % IN: 16 | % len - Scalar length of the output colormap. If len == Inf the concise 17 | % table is returned. Default: len = size(get(gcf, 'Colormap'), 1); 18 | % A - Non-scalar numeric array of real values to be converted into 19 | % truecolor. 20 | % lims - 1x2 array of saturation limits to be used on A. Default: 21 | % [min(A(:)) max(A(:))]. 22 | % 23 | % OUT: 24 | % map - (len)x3 colormap table. 25 | % B - size(A)x3 truecolor array. 26 | 27 | % Copyright: Oliver Woodford, 2009 28 | 29 | function map = winter(varargin) 30 | map = [0 0 1; 0 1 0.5]; 31 | map = colormap_helper(map, varargin{:}); 32 | -------------------------------------------------------------------------------- /helper/splitParser2X.m: -------------------------------------------------------------------------------- 1 | function [split,rows] = splitParser2X(text,field) 2 | %% 3 | if ~iscell(text) 4 | disp('Input text data is not cell array') 5 | end 6 | 7 | split = cell(0); 8 | 9 | [~,loc] = regexpi(text,['^',field,'\w*'],'split'); %Must start with field...different than splitParserX 10 | emptyCells = cellfun(@isempty,loc); 11 | rows = find(emptyCells==0); 12 | 13 | if isempty(rows) 14 | split = text; 15 | else 16 | for i = 1:numel(rows) 17 | if i == numel(rows) 18 | split{end+1,1} = text(rows(i):end); 19 | else 20 | split{end+1,1} = text(rows(i):rows(i+1)-1); 21 | end 22 | end 23 | end 24 | 25 | %% 26 | clearvars -except split rows 27 | -------------------------------------------------------------------------------- /helper/splitParserX.m: -------------------------------------------------------------------------------- 1 | function [split,rows] = splitParserX(text,field) 2 | %% 3 | if ~iscell(text) 4 | disp('Input text data is not cell array') 5 | end 6 | 7 | split = cell(0); 8 | 9 | [~,loc] = regexpi(text,[field,'\w*'],'split'); 10 | emptyCells = cellfun(@isempty,loc); 11 | rows = find(emptyCells==0); 12 | 13 | if isempty(rows) 14 | split = text; 15 | else 16 | for i = 1:numel(rows) 17 | if i == numel(rows) 18 | split{end+1,1} = text(rows(i):end); 19 | else 20 | split{end+1,1} = text(rows(i):rows(i+1)-1); 21 | end 22 | end 23 | end 24 | 25 | %% 26 | clearvars -except split rows 27 | -------------------------------------------------------------------------------- /helper/textParserX.m: -------------------------------------------------------------------------------- 1 | function [str,row] = textParserX(text,field) 2 | %% 3 | if ~iscell(text) 4 | disp('Input text data is not cell array') 5 | end 6 | 7 | for row = 1:numel(text) 8 | if ~isempty(regexpi(text{row},[field,'\w*'])) 9 | str = text{row}; 10 | break 11 | else 12 | str = ' '; 13 | end 14 | end 15 | 16 | if ~strcmpi(str,' ') 17 | [index] = regexpi(str,'"'); 18 | if numel(index) == 2 %Just take the string within quoutes 19 | str = str(index(1)+1:index(2)-1); 20 | else %Otherwise, take whatever is after an = or : 21 | [index] = regexpi(str,'[=:]'); 22 | index = index(1); %Just take the first index in case there are multiple =/: (i.e. time stamps) 23 | 24 | %If there is a space after the delimiting character, ignore it 25 | if strcmpi(str(index+1),' ') 26 | str = str(index+2:end); 27 | else 28 | str = str(index+1:end); 29 | end 30 | 31 | if numel(str) > 0 32 | if strcmpi(str(end),';') 33 | str = strrep(str,';',''); 34 | elseif strcmpi(str(end),',') 35 | str = strrep(str,',',''); 36 | end 37 | end 38 | end 39 | end 40 | 41 | %% 42 | clearvars -except str row 43 | -------------------------------------------------------------------------------- /map/Map Parameter Profiles/misc/zparameters_all.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,on 2 | hist,block_size,31 3 | hist,overlap,15 4 | hist,shift,0 5 | hist,preprocess,None 6 | hist,dim,2D 7 | glcm,toggle,on 8 | glcm,block_size,31 9 | glcm,overlap,15 10 | glcm,shift,0 11 | glcm,preprocess,None 12 | glcm,bd,8 13 | glcm,gl,[0 4095] 14 | glcm,dist,1 15 | glcm,dim,2D 16 | glrlm,toggle,on 17 | glrlm,block_size,31 18 | glrlm,overlap,15 19 | glrlm,shift,0 20 | glrlm,preprocess,None 21 | glrlm,bd,8 22 | glrlm,gl,[0 4095] 23 | glrlm,dim,2D 24 | ngtdm,toggle,on 25 | ngtdm,block_size,31 26 | ngtdm,overlap,15 27 | ngtdm,shift,0 28 | ngtdm,preprocess,None 29 | ngtdm,bd,8 30 | ngtdm,gl,[0 4095] 31 | ngtdm,dist,1 32 | ngtdm,dim,2D 33 | laws2D,toggle,on 34 | laws2D,block_size,31 35 | laws2D,overlap,15 36 | laws2D,shift,0 37 | laws2D,preprocess,None 38 | laws2D,dim,2D 39 | lung,toggle,on 40 | lung,block_size,31 41 | lung,overlap,15 42 | lung,shift,0 43 | lung,preprocess,None 44 | lung,dim,2D 45 | shape,toggle,on 46 | shape,block_size,31 47 | shape,overlap,15 48 | shape,shift,0 49 | shape,dim,2D 50 | -------------------------------------------------------------------------------- /map/Map Parameter Profiles/misc/zparameters_new.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,on 2 | hist,block_size,31 3 | hist,overlap,15 4 | hist,shift,0 5 | hist,preprocess,None 6 | hist,dim,2D 7 | glcm,toggle,on 8 | glcm,block_size,31 9 | glcm,overlap,15 10 | glcm,shift,0 11 | glcm,preprocess,None 12 | glcm,bd,8 13 | glcm,gl,[0 4095] 14 | glcm,dist,1 15 | glcm,dim,2D 16 | glrlm,toggle,on 17 | glrlm,block_size,31 18 | glrlm,overlap,15 19 | glrlm,shift,0 20 | glrlm,preprocess,None 21 | glrlm,bd,8 22 | glrlm,gl,[0 4095] 23 | glrlm,dim,2D 24 | ngtdm,toggle,off 25 | ngtdm,block_size,31 26 | ngtdm,overlap,15 27 | ngtdm,shift,0 28 | ngtdm,preprocess,None 29 | ngtdm,bd,8 30 | ngtdm,gl,[0 4095] 31 | ngtdm,dist,1 32 | ngtdm,dim,2D 33 | laws2D,toggle,off 34 | laws2D,block_size,31 35 | laws2D,overlap,15 36 | laws2D,shift,0 37 | laws2D,preprocess,None 38 | laws2D,dim,2D 39 | lung,toggle,on 40 | lung,block_size,31 41 | lung,overlap,15 42 | lung,shift,0 43 | lung,preprocess,None 44 | lung,dim,2D 45 | shape,toggle,off 46 | shape,block_size,31 47 | shape,overlap,15 48 | shape,shift,0 49 | shape,dim,2D 50 | -------------------------------------------------------------------------------- /map/Map Parameter Profiles/misc/zparameters_overlaps.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,on 2 | hist,block_size,31 3 | hist,overlap,5 4 | hist,overlap,10 5 | hist,overlap,15 6 | hist,shift,0 7 | hist,preprocess,None 8 | hist,dim,2D 9 | glcm,toggle,on 10 | glcm,block_size,31 11 | glcm,overlap,5 12 | glcm,overlap,10 13 | glcm,overlap,15 14 | glcm,shift,0 15 | glcm,preprocess,None 16 | glcm,bd,8 17 | glcm,gl,[0 4095] 18 | glcm,dist,1 19 | glcm,dim,2D 20 | glrlm,toggle,on 21 | glrlm,block_size,31 22 | glrlm,overlap,5 23 | glrlm,overlap,10 24 | glrlm,overlap,15 25 | glrlm,shift,0 26 | glrlm,preprocess,None 27 | glrlm,bd,8 28 | glrlm,gl,[0 4095] 29 | glrlm,dim,2D 30 | ngtdm,toggle,off 31 | ngtdm,block_size,31 32 | ngtdm,overlap,15 33 | ngtdm,shift,0 34 | ngtdm,preprocess,None 35 | ngtdm,bd,8 36 | ngtdm,gl,[0 4095] 37 | ngtdm,dist,1 38 | ngtdm,dim,2D 39 | laws2D,toggle,off 40 | laws2D,block_size,31 41 | laws2D,overlap,15 42 | laws2D,shift,0 43 | laws2D,preprocess,None 44 | laws2D,dim,2D 45 | lung,toggle,on 46 | lung,block_size,31 47 | lung,overlap,5 48 | lung,overlap,10 49 | lung,overlap,15 50 | lung,shift,0 51 | lung,preprocess,None 52 | lung,dim,2D 53 | shape,toggle,off 54 | shape,block_size,31 55 | shape,overlap,15 56 | shape,shift,0 57 | shape,dim,2D 58 | -------------------------------------------------------------------------------- /map/Map Parameter Profiles/misc/zparameters_test_t50_1.trex: -------------------------------------------------------------------------------- 1 | glcm,toggle,on 2 | glcm,block_size,31 3 | glcm,overlap,15 4 | glcm,shift,0 5 | glcm,shift,5 6 | glcm,shift,10 7 | glcm,shift,15 8 | glcm,preprocess,None 9 | glcm,bd,4 10 | glcm,bd,6 11 | glcm,bd,8 12 | glcm,gl,[0 4095] 13 | glcm,dist,1 14 | glcm,dim,2D 15 | -------------------------------------------------------------------------------- /map/Map Parameter Profiles/parameters_average3_filter.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,on 2 | hist,block_size,31 3 | hist,overlap,15 4 | hist,shift,0 5 | hist,preprocess,None 6 | hist,preprocess,Average_3 7 | hist,dim,2D 8 | glcm,toggle,on 9 | glcm,block_size,31 10 | glcm,overlap,15 11 | glcm,shift,0 12 | glcm,preprocess,None 13 | glcm,preprocess,Average_3 14 | glcm,bd,4 15 | glcm,bd,6 16 | glcm,bd,8 17 | glcm,gl,[0 4095] 18 | glcm,dist,1 19 | glcm,dim,2D 20 | glrlm,toggle,on 21 | glrlm,block_size,31 22 | glrlm,overlap,15 23 | glrlm,shift,0 24 | glrlm,preprocess,None 25 | glrlm,preprocess,Average_3 26 | glrlm,bd,4 27 | glrlm,bd,6 28 | glrlm,bd,8 29 | glrlm,gl,[0 4095] 30 | glrlm,dim,2D 31 | ngtdm,toggle,off 32 | ngtdm,block_size,31 33 | ngtdm,overlap,15 34 | ngtdm,shift,0 35 | ngtdm,preprocess,None 36 | ngtdm,preprocess,Average_3 37 | ngtdm,bd,8 38 | ngtdm,gl,[0 4095] 39 | ngtdm,dist,1 40 | ngtdm,dim,2D 41 | laws2D,toggle,off 42 | laws2D,block_size,31 43 | laws2D,overlap,15 44 | laws2D,shift,0 45 | laws2D,preprocess,None 46 | laws2D,preprocess,Average_3 47 | laws2D,dim,2D 48 | lung,toggle,on 49 | lung,block_size,31 50 | lung,overlap,15 51 | lung,shift,0 52 | lung,preprocess,None 53 | lung,preprocess,Average_3 54 | lung,dim,2D 55 | shape,toggle,off 56 | shape,block_size,31 57 | shape,overlap,15 58 | shape,shift,0 59 | shape,dim,2D 60 | -------------------------------------------------------------------------------- /map/Map Parameter Profiles/parameters_average3_filter_15_7.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,on 2 | hist,block_size,15 3 | hist,overlap,7 4 | hist,shift,0 5 | hist,preprocess,None 6 | hist,preprocess,Average_3 7 | hist,dim,2D 8 | glcm,toggle,on 9 | glcm,block_size,15 10 | glcm,overlap,7 11 | glcm,shift,0 12 | glcm,preprocess,None 13 | glcm,preprocess,Average_3 14 | glcm,bd,4 15 | glcm,bd,6 16 | glcm,bd,8 17 | glcm,gl,[0 4095] 18 | glcm,dist,1 19 | glcm,dim,2D 20 | glrlm,toggle,on 21 | glrlm,block_size,15 22 | glrlm,overlap,7 23 | glrlm,shift,0 24 | glrlm,preprocess,None 25 | glrlm,preprocess,Average_3 26 | glrlm,bd,4 27 | glrlm,bd,6 28 | glrlm,bd,8 29 | glrlm,gl,[0 4095] 30 | glrlm,dim,2D 31 | ngtdm,toggle,off 32 | ngtdm,block_size,15 33 | ngtdm,overlap,7 34 | ngtdm,shift,0 35 | ngtdm,preprocess,None 36 | ngtdm,preprocess,Average_3 37 | ngtdm,bd,8 38 | ngtdm,gl,[0 4095] 39 | ngtdm,dist,1 40 | ngtdm,dim,2D 41 | laws2D,toggle,off 42 | laws2D,block_size,15 43 | laws2D,overlap,7 44 | laws2D,shift,0 45 | laws2D,preprocess,None 46 | laws2D,preprocess,Average_3 47 | laws2D,dim,2D 48 | lung,toggle,on 49 | lung,block_size,15 50 | lung,overlap,7 51 | lung,shift,0 52 | lung,preprocess,None 53 | lung,preprocess,Average_3 54 | lung,dim,2D 55 | shape,toggle,off 56 | shape,block_size,15 57 | shape,overlap,7 58 | shape,shift,0 59 | shape,dim,2D 60 | -------------------------------------------------------------------------------- /map/Map Parameter Profiles/parameters_default.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,on 2 | hist,block_size,31 3 | hist,overlap,15 4 | hist,shift,0 5 | hist,preprocess,None 6 | hist,dim,2D 7 | glcm,toggle,on 8 | glcm,block_size,31 9 | glcm,overlap,15 10 | glcm,shift,0 11 | glcm,preprocess,None 12 | glcm,bd,4 13 | glcm,bd,6 14 | glcm,bd,8 15 | glcm,gl,[0 4095] 16 | glcm,dist,1 17 | glcm,dim,2D 18 | glrlm,toggle,on 19 | glrlm,block_size,31 20 | glrlm,overlap,15 21 | glrlm,shift,0 22 | glrlm,preprocess,None 23 | glrlm,bd,4 24 | glrlm,bd,6 25 | glrlm,bd,8 26 | glrlm,gl,[0 4095] 27 | glrlm,dim,2D 28 | ngtdm,toggle,off 29 | ngtdm,block_size,31 30 | ngtdm,overlap,15 31 | ngtdm,shift,0 32 | ngtdm,preprocess,None 33 | ngtdm,bd,8 34 | ngtdm,gl,[0 4095] 35 | ngtdm,dist,1 36 | ngtdm,dim,2D 37 | laws2D,toggle,off 38 | laws2D,block_size,31 39 | laws2D,overlap,15 40 | laws2D,shift,0 41 | laws2D,preprocess,None 42 | laws2D,dim,2D 43 | lung,toggle,on 44 | lung,block_size,31 45 | lung,overlap,15 46 | lung,shift,0 47 | lung,preprocess,None 48 | lung,dim,2D 49 | shape,toggle,off 50 | shape,block_size,31 51 | shape,overlap,15 52 | shape,shift,0 53 | shape,dim,2D 54 | -------------------------------------------------------------------------------- /map/Map Parameter Profiles/parameters_laws_only.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,off 2 | hist,block_size,31 3 | hist,overlap,15 4 | hist,shift,0 5 | hist,preprocess,None 6 | hist,dim,2D 7 | glcm,toggle,off 8 | glcm,block_size,31 9 | glcm,overlap,15 10 | glcm,shift,0 11 | glcm,preprocess,None 12 | glcm,bd,4 13 | glcm,bd,6 14 | glcm,bd,8 15 | glcm,gl,[0 4095] 16 | glcm,dist,1 17 | glcm,dim,2D 18 | glrlm,toggle,off 19 | glrlm,block_size,31 20 | glrlm,overlap,15 21 | glrlm,shift,0 22 | glrlm,preprocess,None 23 | glrlm,bd,4 24 | glrlm,bd,6 25 | glrlm,bd,8 26 | glrlm,gl,[0 4095] 27 | glrlm,dim,2D 28 | ngtdm,toggle,off 29 | ngtdm,block_size,31 30 | ngtdm,overlap,15 31 | ngtdm,shift,0 32 | ngtdm,preprocess,None 33 | ngtdm,bd,8 34 | ngtdm,gl,[0 4095] 35 | ngtdm,dist,1 36 | ngtdm,dim,2D 37 | laws2D,toggle,on 38 | laws2D,block_size,31 39 | laws2D,overlap,15 40 | laws2D,shift,0 41 | laws2D,preprocess,None 42 | laws2D,dim,2D 43 | lung,toggle,off 44 | lung,block_size,31 45 | lung,overlap,15 46 | lung,shift,0 47 | lung,preprocess,None 48 | lung,dim,2D 49 | shape,toggle,off 50 | shape,block_size,31 51 | shape,overlap,15 52 | shape,shift,0 53 | shape,dim,2D 54 | -------------------------------------------------------------------------------- /map/Map Parameter Profiles/parameters_overlaps.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,on 2 | hist,block_size,31 3 | hist,overlap,15 4 | hist,overlap,30 5 | hist,shift,0 6 | hist,preprocess,None 7 | hist,dim,2D 8 | glcm,toggle,on 9 | glcm,block_size,31 10 | glcm,overlap,15 11 | glcm,overlap,30 12 | glcm,shift,0 13 | glcm,preprocess,None 14 | glcm,bd,8 15 | glcm,gl,[0 4095] 16 | glcm,dist,1 17 | glcm,dim,2D 18 | glrlm,toggle,on 19 | glrlm,block_size,31 20 | glrlm,overlap,15 21 | glrlm,overlap,30 22 | glrlm,shift,0 23 | glrlm,preprocess,None 24 | glrlm,bd,8 25 | glrlm,gl,[0 4095] 26 | glrlm,dim,2D 27 | ngtdm,toggle,off 28 | ngtdm,block_size,31 29 | ngtdm,overlap,15 30 | ngtdm,shift,0 31 | ngtdm,preprocess,None 32 | ngtdm,bd,8 33 | ngtdm,gl,[0 4095] 34 | ngtdm,dist,1 35 | ngtdm,dim,2D 36 | laws2D,toggle,off 37 | laws2D,block_size,31 38 | laws2D,overlap,15 39 | laws2D,shift,0 40 | laws2D,preprocess,None 41 | laws2D,dim,2D 42 | lung,toggle,on 43 | lung,block_size,31 44 | lung,overlap,15 45 | lung,overlap,30 46 | lung,shift,0 47 | lung,preprocess,None 48 | lung,dim,2D 49 | shape,toggle,off 50 | shape,block_size,31 51 | shape,overlap,15 52 | shape,shift,0 53 | shape,dim,2D 54 | -------------------------------------------------------------------------------- /map/Map Parameter Profiles/parameters_shifts.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,on 2 | hist,block_size,31 3 | hist,overlap,15 4 | hist,shift,0 5 | hist,shift,5 6 | hist,shift,10 7 | hist,shift,15 8 | hist,preprocess,None 9 | hist,dim,2D 10 | glcm,toggle,on 11 | glcm,block_size,31 12 | glcm,overlap,15 13 | glcm,shift,0 14 | glcm,shift,5 15 | glcm,shift,10 16 | glcm,shift,15 17 | glcm,preprocess,None 18 | glcm,bd,4 19 | glcm,bd,6 20 | glcm,bd,8 21 | glcm,gl,[0 4095] 22 | glcm,dist,1 23 | glcm,dim,2D 24 | glrlm,toggle,on 25 | glrlm,block_size,31 26 | glrlm,overlap,15 27 | glrlm,shift,0 28 | glrlm,shift,5 29 | glrlm,shift,10 30 | glrlm,shift,15 31 | glrlm,preprocess,None 32 | glrlm,bd,4 33 | glrlm,bd,6 34 | glrlm,bd,8 35 | glrlm,gl,[0 4095] 36 | glrlm,dim,2D 37 | ngtdm,toggle,off 38 | ngtdm,block_size,31 39 | ngtdm,overlap,15 40 | ngtdm,shift,0 41 | ngtdm,shift,5 42 | ngtdm,shift,10 43 | ngtdm,shift,15 44 | ngtdm,preprocess,None 45 | ngtdm,bd,8 46 | ngtdm,gl,[0 4095] 47 | ngtdm,dist,1 48 | ngtdm,dim,2D 49 | laws2D,toggle,off 50 | laws2D,block_size,31 51 | laws2D,overlap,15 52 | laws2D,shift,0 53 | laws2D,shift,5 54 | laws2D,shift,10 55 | laws2D,shift,15 56 | laws2D,preprocess,None 57 | laws2D,dim,2D 58 | lung,toggle,on 59 | lung,block_size,31 60 | lung,overlap,15 61 | lung,shift,0 62 | lung,shift,5 63 | lung,shift,10 64 | lung,shift,15 65 | lung,preprocess,None 66 | lung,dim,2D 67 | shape,toggle,off 68 | shape,block_size,31 69 | shape,overlap,15 70 | shape,shift,0 71 | shape,shift,5 72 | shape,shift,10 73 | shape,shift,15 74 | shape,dim,2D 75 | -------------------------------------------------------------------------------- /map/findmapfiles_mapX.m: -------------------------------------------------------------------------------- 1 | function [map_files] = findmapfiles_mapX(project_path,module) 2 | %% 3 | extractRead = read_extractX(project_path,false); 4 | 5 | map_files = cell(0); 6 | 7 | for i = 1:numel(extractRead.patient_mrn) 8 | list = dir(fullfile(extractRead.project_patient{i},'mapx')); 9 | 10 | for fCount = 1:numel(list) 11 | if ~isempty(regexpi(list(fCount).name,['^',module,'.*',extractRead.roi_file{i},'$'])) 12 | map_files{end+1,1} = list(fCount).name; 13 | end 14 | end 15 | end 16 | 17 | %% 18 | clearvars -except map_files 19 | -------------------------------------------------------------------------------- /map/mapX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/map/mapX.fig -------------------------------------------------------------------------------- /map/map_comparison/ccc_mapX.m: -------------------------------------------------------------------------------- 1 | function [ccc] = ccc_mapX(img1,img2) 2 | 3 | v1 = img1(:); 4 | v2 = img2(:); 5 | 6 | ind = isnan(v1); 7 | ind2 = isnan(v2); 8 | if ~isequal(ind,ind2) 9 | error('here') 10 | end 11 | 12 | v1(ind) = []; 13 | v2(ind) = []; 14 | 15 | ccc = corr_ccc_mapX([v1,v2]); 16 | 17 | clearvars -except ccc 18 | 19 | %-------------------------------------------------------------------------- 20 | function [rc] = corr_ccc_mapX(Y) 21 | % INPUT: 22 | % Y - a N*R data matrix 23 | % Based on IPN_ccc in the IPN_toolbox 24 | % REFERENCE: 25 | % Lin, L.I. 1989. A Corcordance Correlation Coefficient to Evaluate 26 | % Reproducibility. Biometrics 45, 255-268. 27 | % 28 | % XINIAN ZUO 2008 29 | % zuoxinian@gmail.com 30 | 31 | Ybar = mean(Y); 32 | S = cov(Y,1); 33 | R = size(Y,2); 34 | tmp = triu(S,1); 35 | rc = 2*sum(tmp(:))/((R-1)*trace(S)+ipn_ssd_mapX(Ybar)); 36 | 37 | clearvars -except rc 38 | 39 | %-------------------------------------------------------------------------- 40 | function [ssd] = ipn_ssd_mapX(X) 41 | % INPUT: 42 | % X - a 1*R data vector 43 | % 44 | % REF: 45 | % Lin, L.I. 1989. A Corcordance Correlation Coefficient to Evaluate 46 | % Reproducibility. Biometrics 45, 255-268. 47 | % 48 | % XINIAN ZUO 2008 49 | % zuoxinian@gmail.com 50 | 51 | R=length(X); 52 | ssd=0; 53 | for k=1:R-1 54 | ssd=ssd+sum((X(k+1:R)-X(k)).*(X(k+1:R)-X(k))); 55 | end 56 | 57 | clearvars -except ssd -------------------------------------------------------------------------------- /map/map_comparison/mi_mapX.m: -------------------------------------------------------------------------------- 1 | function [MI,D] = mi_mapX(img1,img2,binSize) 2 | 3 | img1 = double(img1(:)); %Vectorize!!! 4 | img2 = double(img2(:)); 5 | 6 | %% 7 | min_xy = min([img1; img2]); 8 | max_xy = max([img1; img2]); 9 | 10 | % std_xy = std([img1; img2]); 11 | % %binSize = 1; %If we are dealing with an integer array 12 | % binSize = (max_xy-min_xy)/std_xy*5; %I suggest: binSize=range(y)/std(y)*5; 13 | 14 | bins = min_xy:binSize:max_xy; 15 | %% 16 | % Entropy of img1 17 | % Generate the histogram 18 | [n, xout] = hist(img1, bins); 19 | 20 | % Normalize the area of the histogram to make it a pdf 21 | n = n/sum(n); 22 | b = xout(2)-xout(1); 23 | 24 | % Calculate the entropy 25 | indices = (n ~= 0); 26 | Hx = -sum(n(indices).*log2(n(indices)).*b); 27 | 28 | %% 29 | % Entropy of img2 30 | % Generate the histogram 31 | [n, xout] = hist(img2(:), bins); 32 | 33 | % Normalize the area of the histogram to make it a pdf 34 | n = n/sum(n); 35 | b = xout(2)-xout(1); 36 | 37 | % Calculate the entropy 38 | indices = (n ~= 0); 39 | Hy = -sum(n(indices).*log2(n(indices)).*b); 40 | 41 | %% 42 | [N,C] = hist3([img1(:),img2(:)],{bins; bins}); 43 | 44 | hx = C{1,1}; 45 | hy = C{1,2}; 46 | 47 | % Normalize the area of the histogram to make it a pdf 48 | N = N/sum(N(:)); 49 | b = hx(2)-hx(1); 50 | l = hy(2)-hy(1); 51 | 52 | % Calculate the entropy 53 | indices = N ~= 0; 54 | Hxy = -b*l*sum(N(indices).*log2(N(indices))); 55 | 56 | MI = Hx + Hy - Hxy; 57 | D = 1 - MI/Hxy; %metric, normalized distance 58 | -------------------------------------------------------------------------------- /map/map_comparison/mi_mapX_uint8.m: -------------------------------------------------------------------------------- 1 | function MI = mi_mapX_uint8(img1,img2) 2 | % function h=MI2(image_1,image_2,method) 3 | % 4 | % Takes a pair of images and returns the mutual information Ixy using joint entropy function JOINT_H.m 5 | % 6 | % written by http://www.flash.net/~strider2/matlab.htm 7 | 8 | 9 | %% 10 | rows=size(img1,1); 11 | cols=size(img2,2); 12 | N=256; 13 | 14 | h=zeros(N,N); 15 | 16 | for i=1:rows; % col 17 | for j=1:cols; % rows 18 | h(img1(i,j)+1,img2(i,j)+1) = h(img1(i,j)+1,img2(i,j)+1) + 1; 19 | end 20 | end 21 | 22 | %% 23 | [r,c] = size(h); 24 | b = h./(r*c); % normalized joint histogram 25 | %% 26 | y_marg = sum(b); %sum of the rows of normalized joint histogram 27 | x_marg = sum(b,2)';%sum of columns of normalized joint histogran 28 | %% 29 | Hy=0; 30 | for i=1:numel(y_marg) 31 | if(y_marg(i)==0) 32 | %do nothing 33 | else 34 | Hy = Hy + -(y_marg(i)*(log2(y_marg(i)))); %marginal entropy for image 1 35 | end 36 | end 37 | 38 | Hx=0; 39 | for i=1:numel(x_marg) 40 | if(x_marg(i)==0) 41 | %do nothing 42 | else 43 | Hx = Hx + -(x_marg(i)*(log2(x_marg(i)))); %marginal entropy for image 2 44 | end 45 | end 46 | %% 47 | h_xy = -sum(sum(b.*log2(b+(b==0)))); % joint entropy 48 | %% 49 | 50 | MI = Hx + Hy - h_xy;% Mutual information 51 | D = 1 - MI/h_xy; %metric, normalized distance 52 | 53 | -------------------------------------------------------------------------------- /map/map_comparison/outcome_compare_doseX.m: -------------------------------------------------------------------------------- 1 | function [out,ccc,spear] = outcome_compare_doseX(project_path,patient_mrn,outcome) 2 | 3 | %% 4 | [extractRead] = read_extractX(project_path,false); 5 | 6 | fields = fieldnames(extractRead); 7 | 8 | %% 9 | %Patient mrns to keep 10 | [~,ind_keep] = intersect(extractRead.patient_mrn, patient_mrn); 11 | for fCount = 1:numel(fields) 12 | extractRead.(fields{fCount}) = extractRead.(fields{fCount})(ind_keep,:); 13 | end 14 | 15 | % isequal(doseRead.patient_mrn,patient.mrn) 16 | 17 | %% 18 | out.all = []; 19 | mask_all = []; 20 | 21 | for entry = 1:numel(extractRead.patient_mrn) 22 | filepath = fullfile(extractRead.project_patient{entry}, extractRead.dose_file{entry}); 23 | dose = load(filepath,'array'); 24 | out.all(:,end+1) = dose.array(:); 25 | 26 | filepath = fullfile(extractRead.project_patient{entry}, extractRead.roi_file{entry}); 27 | mask = load(filepath,'mask'); 28 | mask_all(:,end+1) = mask.mask(:); 29 | end 30 | 31 | %% 32 | mask_all = double(mask_all); 33 | mask_all(mask_all == 0) = nan; 34 | out.all = out.all.*mask_all; 35 | 36 | %% 37 | %Require at least 75% of patients to have a non-nan value 38 | out.all(sum(isnan(out.all),2)/size(out.all,2) >= 0.75, :) = nan; 39 | 40 | %% 41 | out.all_true = out.all(:, outcome); 42 | out.all_false = out.all(:, ~outcome); 43 | 44 | %MEAN 45 | % out.true = nanmean(out.all_true,2); 46 | % out.false = nanmean(out.all_false,2); 47 | 48 | %MEDIAN 49 | out.true = nanmedian(out.all_true,2); 50 | out.false = nanmedian(out.all_false,2); 51 | 52 | out.true = reshape(out.true,extractRead.image_ydim(1),extractRead.image_xdim(1),extractRead.image_zdim(1)); 53 | out.false = reshape(out.false,extractRead.image_ydim(1),extractRead.image_xdim(1),extractRead.image_zdim(1)); 54 | out.diff = out.true - out.false; 55 | 56 | %% 57 | out.spearman = []; 58 | for i = 1:size(out.all,1) 59 | out.spearman(i,1) = corr(out.all(i,:)',outcome,'type','Spearman','rows','complete'); 60 | [~,out.ttest(i,1)] = ttest2(out.all(i,outcome)',out.all(i,~outcome)'); 61 | end 62 | 63 | out.spearman = reshape(out.spearman,extractRead.image_ydim(1),extractRead.image_xdim(1),extractRead.image_zdim(1)); 64 | out.ttest = reshape(out.ttest,extractRead.image_ydim(1),extractRead.image_xdim(1),extractRead.image_zdim(1)); 65 | 66 | %% 67 | ccc = ccc_mapX(out.true,out.false); 68 | spear = spearman_mapX(out.true,out.false); 69 | 70 | %% 71 | clearvars -except out ccc spear 72 | -------------------------------------------------------------------------------- /map/map_comparison/psnr_mapX.m: -------------------------------------------------------------------------------- 1 | function [psnr,mse] = psnr_mapX(img1,img2) 2 | 3 | img_max = max(max(img1(:)),max(img2(:))); 4 | dif = img1(:)-img2(:); 5 | mse = nanmean(dif.^2); 6 | psnr = 10*log(img_max*img_max/mse)/log(10); -------------------------------------------------------------------------------- /map/map_comparison/spearman_mapX.m: -------------------------------------------------------------------------------- 1 | function [spear] = spearman_mapX(img1,img2) 2 | 3 | v1 = img1(:); 4 | v2 = img2(:); 5 | 6 | ind = isnan(v1); 7 | ind2 = isnan(v2); 8 | if ~isequal(ind,ind2) 9 | error('here') 10 | end 11 | 12 | v1(ind) = []; 13 | v2(ind) = []; 14 | 15 | [spear] = corr(v1,v2,'type','spearman'); 16 | 17 | clearvars -except spear 18 | 19 | -------------------------------------------------------------------------------- /map/map_comparison/ssim_mapX.m: -------------------------------------------------------------------------------- 1 | function [mssim,ssim_map] = ssim_mapX(img1,img2,varargin) 2 | 3 | hsize = 11; 4 | if nargin == 3 5 | hsize = varargin{1}; 6 | end 7 | 8 | h = fspecial('gaussian',hsize,1.5); 9 | K(1) = 0.01; 10 | K(2) = 0.03; 11 | L = 1; 12 | 13 | C1 = (K(1)*L)^2; 14 | C2 = (K(2)*L)^2; 15 | img1 = double(img1); 16 | img2 = double(img2); 17 | 18 | %% 19 | 20 | mu1 = imfilter(img1,h); 21 | mu2 = imfilter(img2,h); 22 | 23 | %% 24 | mu1_sq = mu1.*mu1; 25 | mu2_sq = mu2.*mu2; 26 | mu1_mu2 = mu1.*mu2; 27 | 28 | %% 29 | 30 | sigma1_sq = imfilter(img1.*img1,h); 31 | sigma2_sq = imfilter(img2.*img2,h); 32 | sigma12 = imfilter(img1.*img2,h); 33 | 34 | %% 35 | sigma1_sq = sigma1_sq - mu1_sq; 36 | sigma2_sq = sigma2_sq - mu2_sq; 37 | sigma12 = sigma12 - mu1_mu2; 38 | 39 | %% 40 | 41 | 42 | ssim_map = ((2*mu1_mu2 + C1).*(2*sigma12 + C2))./((mu1_sq + mu2_sq + C1).*(sigma1_sq + sigma2_sq + C2)); 43 | %% 44 | mssim = nanmean(ssim_map(:)); 45 | 46 | -------------------------------------------------------------------------------- /map/map_modules/mask_points.m: -------------------------------------------------------------------------------- 1 | function [X,Y,Z] = mask_points(mask,block_size,overlap,shift,dim) 2 | %% 3 | [size_y,size_x,size_z] = size(mask); 4 | 5 | step = block_size-overlap; 6 | 7 | xV = shift:step:size(mask,2); 8 | yV = shift:step:size(mask,1); 9 | if strcmpi(dim,'3D') 10 | zV = shift:step:size(mask,3); 11 | else 12 | zV = 1:1:size(mask,3); 13 | end 14 | 15 | [X,Y,Z] = meshgrid(xV,yV,zV); 16 | X = X(:); 17 | Y = Y(:); 18 | Z = Z(:); 19 | 20 | %% 21 | %Lower and upper bound for each block centered X, Y, Z 22 | X_low = X - floor(block_size/2); 23 | X_up = X + ceil(block_size/2) - 1; 24 | 25 | Y_low = Y - floor(block_size/2); 26 | Y_up = Y + ceil(block_size/2) - 1; 27 | 28 | if strcmpi(dim,'3D') 29 | Z_low = Z - floor(block_size/2); 30 | Z_up = Z + ceil(block_size/2) - 1; 31 | else 32 | Z_low = Z; 33 | Z_up = Z; 34 | end 35 | 36 | %If part of the block falls outside the slice, get rid of it 37 | ind = X_low < 1 | X_up > size_x | Y_low < 1 | Y_up > size_y | Z_low < 1 | Z_up > size_z; 38 | X_low(ind) = []; 39 | X(ind) = []; 40 | X_up(ind) = []; 41 | Y_low(ind) = []; 42 | Y(ind) = []; 43 | Y_up(ind) = []; 44 | Z_low(ind) = []; 45 | Z(ind) = []; 46 | Z_up(ind) = []; 47 | 48 | %% 49 | %If the block is centered on pixel that is outside the mask, get rid of it 50 | index = Y + (X-1)*size_y + (Z-1)*size_y*size_x; 51 | ind = mask(index) == false; 52 | X_low(ind) = []; 53 | X(ind) = []; 54 | X_up(ind) = []; 55 | Y_low(ind) = []; 56 | Y(ind) = []; 57 | Y_up(ind) = []; 58 | Z_low(ind) = []; 59 | Z(ind) = []; 60 | Z_up(ind) = []; 61 | 62 | % Cat points 63 | X = [X_low,X,X_up]; 64 | Y = [Y_low,Y,Y_up]; 65 | Z = [Z_low,Z,Z_up]; 66 | 67 | %% 68 | clearvars -except X Y Z 69 | -------------------------------------------------------------------------------- /map/map_parameters/profileread_mapX.m: -------------------------------------------------------------------------------- 1 | function [h] = profileread_mapX(h,profile) 2 | %% Read parameter profile list and sort into appropriate fields 3 | for i = 1:size(profile,1) 4 | module = profile{i,1}; 5 | parameter = profile{i,2}; 6 | 7 | if strcmpi(parameter,'toggle') 8 | h.(module).(parameter) = profile{i,3}; 9 | else 10 | h.(module).(parameter){end+1,1} = profile{i,3}; 11 | end 12 | end 13 | 14 | %% 15 | clearvars -except h 16 | -------------------------------------------------------------------------------- /map/map_parameters/profilewrite_mapX.m: -------------------------------------------------------------------------------- 1 | function [profile] = profilewrite_mapX(h) 2 | %%Write the texture parameter profile to a cell array. 3 | profile = cell(0); 4 | 5 | for i = 1:numel(h.module_names) 6 | module = h.module_names{i}; 7 | parameters = fieldnames(h.(module)); 8 | 9 | for j = 1:numel(parameters) 10 | if ischar(h.(module).(parameters{j})) 11 | profile{end+1,1} = module; 12 | profile{end,2} = parameters{j}; 13 | profile{end,3} = h.(module).(parameters{j}); 14 | 15 | else 16 | for k = 1:numel(h.(module).(parameters{j})) 17 | profile{end+1,1} = module; 18 | profile{end,2} = parameters{j}; 19 | profile{end,3} = h.(module).(parameters{j}){k}; 20 | end 21 | end 22 | end 23 | end 24 | 25 | %% 26 | clearvars -except profile 27 | -------------------------------------------------------------------------------- /map/move_mapX.m: -------------------------------------------------------------------------------- 1 | function move_mapX(project_dir,new_dir) 2 | 3 | dir_list = dir(project_dir); 4 | 5 | [~,project_name] = fileparts(project_dir); 6 | 7 | for i = 1:numel(dir_list) 8 | if dir_list(i).isdir 9 | 10 | list = dir(fullfile(project_dir,dir_list(i).name)); 11 | 12 | if sum(strcmpi({list.name},'mapx')) == 1 13 | movefile(fullfile(project_dir,dir_list(i).name,'mapx'),fullfile(new_dir,project_name,dir_list(i).name,'mapx')) 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /map/norm_mapX.m: -------------------------------------------------------------------------------- 1 | function [J] = norm_mapX(I,out_rng,varargin) 2 | %% 3 | if nargin > 2 4 | in_rng = varargin{1}; 5 | else 6 | %Remove any significant outliers (similar to matlab stretchlim function 7 | p1 = prctile(I(:),1); 8 | p99 = prctile(I(:),99); 9 | I(I>p99) = p99; 10 | I(I out_rng(2)) = out_rng(2); 20 | J(J < out_rng(1)) = out_rng(1); 21 | 22 | %% 23 | clearvars -except J 24 | -------------------------------------------------------------------------------- /map/nuke_mapX.m: -------------------------------------------------------------------------------- 1 | function nuke_mapX(project_dir) 2 | 3 | dir_list = dir(project_dir); 4 | 5 | for i = 1:numel(dir_list) 6 | if dir_list(i).isdir 7 | 8 | list = dir(fullfile(project_dir,dir_list(i).name)); 9 | 10 | if sum(strcmpi({list.name},'mapx')) == 1 11 | rmdir(fullfile(project_dir,dir_list(i).name,'mapx'),'s') 12 | end 13 | end 14 | end -------------------------------------------------------------------------------- /map/percentile_mapX.m: -------------------------------------------------------------------------------- 1 | function [J] = percentile_mapX(I) 2 | %% 3 | A = I(:); 4 | ind_a = ~isnan(A); 5 | A = A(ind_a); 6 | 7 | %% 8 | [B,~,ind_b] = unique(A); 9 | 10 | %% 11 | [f,x] = ecdf(B); 12 | 13 | x = x(2:end); 14 | f = f(2:end); 15 | 16 | %% 17 | b = f(ind_b); 18 | 19 | %% 20 | J = nan(size(I)); 21 | J(ind_a) = b; 22 | 23 | %% 24 | clearvars -except J 25 | 26 | -------------------------------------------------------------------------------- /map/standardize_mapX.m: -------------------------------------------------------------------------------- 1 | function [J] = standardize_mapX(I) 2 | %% 3 | mean_I = nanmean(I(:)); 4 | std_I = nanstd(I(:)); 5 | 6 | J = (I - mean_I)/std_I; 7 | 8 | %% 9 | clearvars -except J 10 | -------------------------------------------------------------------------------- /map/start_mapX.m: -------------------------------------------------------------------------------- 1 | function [h] = start_mapX(h) 2 | %% 3 | set(h.push_start,'Enable','off') 4 | start = tic; 5 | 6 | disp('TREX-RT>> Texture map extraction started...') 7 | 8 | %% Run each module 9 | for i = 1:numel(h.module_names) 10 | module = h.module_names{i}; 11 | if strcmpi(h.(module).toggle,'on') 12 | h = startmodule_mapX(h,module); 13 | end 14 | pause(0.001) 15 | end 16 | 17 | %% 18 | set(h.text_wait2,'String','Texture map extraction complete!') 19 | drawnow; pause(0.001); 20 | disp('TREX-RT>> Texture map Extraction Complete!') 21 | disp(['TREX-RT>> Total MapX run time: ',num2str(toc(start)),' seconds']) 22 | 23 | %% 24 | clearvars -except h 25 | -------------------------------------------------------------------------------- /misc/Figure TREX 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/misc/Figure TREX 1.png -------------------------------------------------------------------------------- /misc/Figure TREX 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/misc/Figure TREX 2.png -------------------------------------------------------------------------------- /misc/Figure TREX 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/misc/Figure TREX 3.png -------------------------------------------------------------------------------- /misc/Figure TREX 4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/misc/Figure TREX 4.png -------------------------------------------------------------------------------- /misc/Figure TREX 5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/misc/Figure TREX 5.png -------------------------------------------------------------------------------- /misc/appendix_dosimetric.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/misc/appendix_dosimetric.pdf -------------------------------------------------------------------------------- /misc/appendix_radiomics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/misc/appendix_radiomics.pdf -------------------------------------------------------------------------------- /project/batchX/addjobX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/project/batchX/addjobX.fig -------------------------------------------------------------------------------- /project/batchX/batchX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/project/batchX/batchX.fig -------------------------------------------------------------------------------- /project/cleanup_logX.m: -------------------------------------------------------------------------------- 1 | function cleanup_logX(project_path) 2 | 3 | %% 4 | modules = {'setup',... 5 | 'extract'}; 6 | 7 | dose = parameterfields_doseX([]); 8 | tex = parameterfields_textureX([]); 9 | map = parameterfields_mapX([]); 10 | 11 | modules = [modules,strcat(dose.module_names,'_dose'),strcat(tex.module_names,'_texture'),strcat(map.module_names,'_map')]; 12 | 13 | rundata = cell(0); 14 | for i = 1:numel(modules) 15 | date = getDate_logX(project_path,modules{i}); 16 | rundata{end+1,1} = modules{i}; 17 | rundata{end,2} = date; 18 | end 19 | %% 20 | filenames = cell(0); 21 | list = dir(fullfile(project_path,'Log')); 22 | for i = 1:numel(list) 23 | if ~isempty(regexpi(list(i).name,'.mat$')) || ~isempty(regexpi(list(i).name,'.xlog$')) 24 | filenames{end+1,1} = list(i).name; 25 | end 26 | end 27 | 28 | %% 29 | keep = false(size(filenames)); 30 | for i = 1:size(rundata,1) 31 | if rundata{i,2} ~= 0 32 | keep = ~cellfun(@isempty,regexpi(filenames,[num2str(rundata{i,2}),'_',rundata{i,1},'(\w*)X.mat'])) | keep; 33 | end 34 | end 35 | 36 | %% 37 | [s,mess,messid] = mkdir(fullfile(project_path,'Log'),'old'); 38 | 39 | for i = 1:numel(keep) 40 | if ~keep(i) 41 | %filenames{i} 42 | movefile(fullfile(project_path,'Log',filenames{i}),fullfile(project_path,'Log','old',filenames{i})) 43 | end 44 | end 45 | 46 | %% 47 | clearvars -------------------------------------------------------------------------------- /project/cleanup_projectX.m: -------------------------------------------------------------------------------- 1 | function cleanup_projectX(project_path) 2 | %Function to remove all of the Raw Data directories from a chosen Project 3 | 4 | list = dir(project_path); 5 | 6 | w = waitbar(0,'Please wait...'); 7 | steps = numel(list); 8 | 9 | for i = 1:numel(list) 10 | if list(i).isdir && numel(list(i).name) > 2 11 | path = fullfile(project_path,list(i).name,'Pinnacle Data'); 12 | path_exist = exist(path,'dir'); 13 | 14 | if path_exist == 7 15 | stat = rmdir(path,'s'); 16 | 17 | if stat == 1 18 | disp(['TREX-RT>> ',fullfile(project_path,list(i).name,'Pinnacle Data'),' deleted']) 19 | else 20 | disp(['TREX-RT>> ***',fullfile(project_path,list(i).name,'Pinnacle Data'),' failed to delete']) 21 | end 22 | end 23 | end 24 | 25 | waitbar(i/steps,w) 26 | end 27 | 28 | close(w) 29 | -------------------------------------------------------------------------------- /project/cleanup_roidataX.m: -------------------------------------------------------------------------------- 1 | function cleanup_roidataX(project_path) 2 | 3 | extractRead = read_extractX(project_path); 4 | 5 | h = waitbar(0, 'Please wait...'); 6 | 7 | for j = 1:numel(extractRead.project_path) 8 | 9 | waitbar(j/numel(extractRead.project_path),h) 10 | 11 | roi = load(fullfile(extractRead.project_patient{j},extractRead.roi_file{j})); 12 | %% 13 | namelist = cell(0); 14 | for cellInd = 1:numel(roi.data) 15 | namelist{end+1,1} = textParserX(roi.data{cellInd},'name'); 16 | end 17 | 18 | names = cell(0); 19 | if ~isempty(roi.roi_source) 20 | names = [names,regexpi(roi.roi_source,'/','split')]; 21 | end 22 | 23 | if ~isempty(roi.roi_int) 24 | names = [names,regexpi(roi.roi_int,'/','split')]; 25 | end 26 | 27 | if ~isempty(roi.roi_ext) 28 | names = [names,regexpi(roi.roi_ext,'/','split')]; 29 | end 30 | 31 | for i = numel(names):-1:1 32 | if ~isempty(regexpi(names{i},'Subvolume')) 33 | i1 = regexpi(names{i},'('); 34 | names{i} = names{i}(1:i1-2); 35 | elseif ~isempty(roi.dose_name) && ~isempty(regexpi(names{i},['(',roi.dose_name,')'])) 36 | names(i) = []; 37 | end 38 | end 39 | 40 | names = unique(names); 41 | 42 | [~,keep_ind] = intersect(namelist,names); 43 | roi.data = roi.data(keep_ind); 44 | 45 | %% 46 | save(fullfile(extractRead.project_patient{j},extractRead.roi_file{j}), '-struct', 'roi') 47 | 48 | end 49 | 50 | close(h) 51 | -------------------------------------------------------------------------------- /project/projectX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/project/projectX.fig -------------------------------------------------------------------------------- /project/update_projectX.m: -------------------------------------------------------------------------------- 1 | function update_projectX(varargin) 2 | %% 3 | % if ~isempty(varargin) 4 | % project_path = varargin{1}; 5 | % else 6 | % project_path = uigetdir(pwd,'Select Project Directory'); 7 | % end 8 | 9 | % %% 10 | % remove_textureX(project_path) 11 | % if exist(fullfile(project_path,'SHAPE.mat'),'file') == 2 12 | % delete(fullfile(project_path,'SHAPE.mat')) 13 | % end 14 | % 15 | % remove_doseX(project_path) 16 | % if exist(fullfile(project_path,'DMH.mat'),'file') == 2 17 | % delete(fullfile(project_path,'DMH.mat')) 18 | % end 19 | % 20 | % %% 21 | % try 22 | % [moduleRead,filename] = read_doseX(project_path,'dvh'); 23 | % moduleRead = rmfield(moduleRead,'feature_NumVoxels'); 24 | % save(fullfile(project_path,'Log',filename),'-struct','moduleRead') 25 | % catch err 26 | % 27 | % end 28 | 29 | %% 30 | % try 31 | % [moduleRead,filename] = read_textureX(project_path,'lung'); 32 | % delete(fullfile(project_path,'Log',filename)) 33 | % catch err 34 | % 35 | % end 36 | 37 | %% 38 | % h = waitbar(0,'Project Update In Progress...'); 39 | % 40 | % %% 41 | % close(h) 42 | % 43 | % clear 44 | 45 | -------------------------------------------------------------------------------- /project/writeX/link_writeX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/project/writeX/link_writeX.fig -------------------------------------------------------------------------------- /project/writeX/writeX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/project/writeX/writeX.fig -------------------------------------------------------------------------------- /setup/pinnacle_setupX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/setup/pinnacle_setupX.fig -------------------------------------------------------------------------------- /setup/pinnacle_setupX/drop_dose_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = drop_dose_pinnacle_setupX(h) 2 | %% 3 | set(h.push_doseinfo,'Enable','off') 4 | set(h.menu_doseinfo,'Enable','off') 5 | 6 | set(h.push_displaydose,'Enable','off') 7 | set(h.push_displaydose,'Value',0) 8 | set(h.menu_displaydose,'Enable','off') 9 | set(h.menu_displaydose,'Checked','off') 10 | 11 | h.dosetoggle = false; 12 | h.dose = []; 13 | 14 | axes_main_setupX(h) 15 | axes_minor1_setupX(h) 16 | axes_minor2_setupX(h) 17 | 18 | h.export.dose_name = h.dose_namelist{get(h.drop_dose,'Value')}; 19 | h.export.dose_internalUID = dicomuid; 20 | 21 | h = suspendhandles_pinnacle_setupX(h); 22 | 23 | if ~strcmpi(h.export.dose_name,'') 24 | disp('TREX-RT>> Checking dose array data...'); 25 | h = doseInfo_pinnacle_setupX(h); %This makes call to readDose as well 26 | end 27 | 28 | restorehandles_pinnacle_setupX(h) 29 | 30 | if isempty(h.dose) 31 | h.export.dose_name = []; 32 | h.export.dose_internalUID = []; 33 | 34 | set(h.drop_dose,'Value',1) 35 | else 36 | disp(['TREX-RT>> Selected Dose Trial: ',h.export.dose_name]); 37 | 38 | set(h.push_doseinfo,'Enable','on') 39 | set(h.menu_doseinfo,'Enable','on') 40 | set(h.push_displaydose,'Enable','on') 41 | set(h.menu_displaydose,'Enable','on') 42 | end 43 | 44 | %% 45 | clearvars -except h 46 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/drop_institution_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = drop_institution_pinnacle_setupX(h) 2 | %% 3 | set(h.push_add,'Enable','off') 4 | set(h.push_remove,'Enable','off') 5 | 6 | h = handlesoff_pinnacle_setupX(h,'patient'); 7 | h = handlesoff_pinnacle_setupX(h,'plan'); 8 | h = handlesoff_pinnacle_setupX(h,'image'); 9 | h = handlesoff_pinnacle_setupX(h,'roi'); 10 | h = handlesoff_pinnacle_setupX(h,'dose'); 11 | 12 | axes_main_setupX(h) 13 | axes_minor1_setupX(h) 14 | axes_minor2_setupX(h) 15 | 16 | h.export = resetexport_pinnacle_setupX(h.export,'institution'); 17 | h.export = resetexport_pinnacle_setupX(h.export,'patient'); 18 | h.export = resetexport_pinnacle_setupX(h.export,'plan'); 19 | h.export = resetexport_pinnacle_setupX(h.export,'image'); 20 | h.export = resetexport_pinnacle_setupX(h.export,'roi'); 21 | h.export = resetexport_pinnacle_setupX(h.export,'dose'); 22 | 23 | disp('TREX-RT>> Gathering institution info...') 24 | 25 | h.export.institution_path = h.institution_pathlist{get(h.drop_institution,'Value')}; 26 | h.export.institution_dir = h.institution_dirlist{get(h.drop_institution,'Value')}; 27 | 28 | h = suspendhandles_pinnacle_setupX(h); 29 | 30 | %Get the list of files within the institution directory and transfer the 31 | %institution file to the project directory 32 | if h.export.remote 33 | cd(h.ftp,h.export.institution_path); 34 | drawnow; pause(0.1); 35 | inst_file = mget(h.ftp,'Institution',h.export.project_path); 36 | inst_file = inst_file{1}; 37 | cd(h.ftp,h.export.home_path); 38 | else 39 | copyfile(fullfile(h.export.institution_path,'Institution'),h.export.project_path); 40 | inst_file = fullfile(h.export.project_path,'Institution'); 41 | end 42 | 43 | %Open, read, and close the institution file 44 | fid = fopen(inst_file); 45 | h.filedata.institution = textscan(fid,'%s','delimiter','\n'); 46 | h.filedata.institution = h.filedata.institution{1}; 47 | fclose(fid); 48 | 49 | h.export.institution_name = textParserX(h.filedata.institution,'Name '); 50 | h.export.institution_street = textParserX(h.filedata.institution,'StreetAddress '); 51 | h.export.institution_street2 = textParserX(h.filedata.institution,'StreetAddress2 '); 52 | 53 | %clear institution 54 | delete(inst_file) 55 | 56 | restorehandles_pinnacle_setupX(h) 57 | 58 | disp(['TREX-RT>> ',h.export.institution_dir,': ',h.export.institution_name,', ',h.export.institution_street,', ',h.export.institution_street2]); 59 | 60 | set(h.push_institution,'Enable','on') 61 | 62 | %% 63 | clearvars -except h 64 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/drop_patient_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = drop_patient_pinnacle_setupX(h) 2 | %% 3 | set(h.push_add,'Enable','off') 4 | set(h.push_remove,'Enable','off') 5 | 6 | h = handlesoff_pinnacle_setupX(h,'plan'); 7 | h = handlesoff_pinnacle_setupX(h,'image'); 8 | h = handlesoff_pinnacle_setupX(h,'roi'); 9 | h = handlesoff_pinnacle_setupX(h,'dose'); 10 | 11 | axes_main_setupX(h) 12 | axes_minor1_setupX(h) 13 | axes_minor2_setupX(h) 14 | 15 | h.export = resetexport_pinnacle_setupX(h.export,'patient'); 16 | h.export = resetexport_pinnacle_setupX(h.export,'plan'); 17 | h.export = resetexport_pinnacle_setupX(h.export,'image'); 18 | h.export = resetexport_pinnacle_setupX(h.export,'roi'); 19 | h.export = resetexport_pinnacle_setupX(h.export,'dose'); 20 | 21 | disp('TREX-RT>> Gathering patient info...') 22 | 23 | h.export.patient_path = h.patient_pathlist{get(h.drop_patient,'Value')}; 24 | h.export.patient_dir = h.patient_dirlist{get(h.drop_patient,'Value')}; 25 | 26 | h = suspendhandles_pinnacle_setupX(h); 27 | 28 | %Get the list of files within the patient directory and transfer the 29 | %patient file to the project directory 30 | if h.export.remote 31 | cd(h.ftp,h.export.patient_path); 32 | drawnow; pause(0.1); 33 | pat_file = mget(h.ftp,'Patient',h.export.project_path); 34 | pat_file = pat_file{1}; 35 | cd(h.ftp,h.export.home_path); 36 | else 37 | copyfile(fullfile(h.export.patient_path,'Patient'),h.export.project_path); 38 | pat_file = fullfile(h.export.project_path,'Patient'); 39 | end 40 | 41 | %Open, read, and close the patient file 42 | fid = fopen(pat_file); 43 | h.filedata.patient = textscan(fid,'%s','delimiter','\n'); 44 | h.filedata.patient = h.filedata.patient{1}; 45 | fclose(fid); 46 | 47 | last = textParserX(h.filedata.patient,'LastName '); 48 | first = textParserX(h.filedata.patient,'FirstName '); 49 | h.export.patient_name = [last,', ',first]; 50 | h.export.patient_mrn = str2double(textParserX(h.filedata.patient,'MedicalRecordNumber ')); 51 | 52 | delete(pat_file) 53 | 54 | restorehandles_pinnacle_setupX(h) 55 | 56 | disp(['TREX-RT>> ',h.export.patient_dir,': ',h.export.patient_name,', ',num2str(h.export.patient_mrn)]); 57 | 58 | set(h.push_patient,'Enable','on') 59 | 60 | %% 61 | clearvars -except h 62 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/drop_plan_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = drop_plan_pinnacle_setupX(h) 2 | %% 3 | set(h.push_add,'Enable','off') 4 | set(h.push_remove,'Enable','off') 5 | 6 | h = handlesoff_pinnacle_setupX(h,'image'); 7 | h = handlesoff_pinnacle_setupX(h,'roi'); 8 | h = handlesoff_pinnacle_setupX(h,'dose'); 9 | 10 | axes_main_setupX(h) 11 | axes_minor1_setupX(h) 12 | axes_minor2_setupX(h) 13 | 14 | h.export = resetexport_pinnacle_setupX(h.export,'plan'); 15 | h.export = resetexport_pinnacle_setupX(h.export,'image'); 16 | h.export = resetexport_pinnacle_setupX(h.export,'roi'); 17 | h.export = resetexport_pinnacle_setupX(h.export,'dose'); 18 | 19 | h.export.plan_path = h.plan_pathlist{get(h.drop_plan,'Value')}; 20 | h.export.plan_dir = h.plan_dirlist{get(h.drop_plan,'Value')}; 21 | h.export.plan_id = h.plan_idlist{get(h.drop_plan,'Value')}; 22 | h.export.plan_name = h.plan_namelist{get(h.drop_plan,'Value')}; 23 | 24 | disp('TREX-RT>> Gathering plan info...'); 25 | disp(['TREX-RT>> ',h.export.plan_dir,': ',h.export.plan_name]); 26 | 27 | set(h.push_plan,'Enable','on') 28 | 29 | %% 30 | clearvars -except h 31 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/drop_roi_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = drop_roi_pinnacle_setupX(h) 2 | %% 3 | set(h.push_add,'Enable','off') 4 | set(h.push_remove,'Enable','off') 5 | 6 | h.roitoggle_curve = false; 7 | h.roi.curvedata = []; 8 | 9 | axes_main_setupX(h) 10 | axes_minor1_setupX(h) 11 | axes_minor2_setupX(h) 12 | 13 | h.export.roi_name = h.roi_namelist{get(h.drop_roi,'Value')}; 14 | h.export.roi_source = h.export.roi_name; 15 | h.export.roi_int = []; 16 | h.export.roi_ext = []; 17 | 18 | disp(['TREX-RT>> Selected ROI: ',h.export.roi_name]); 19 | 20 | set(h.push_displaycurveroi,'Enable','on') 21 | set(h.menu_displaycurveroi,'Enable','on') 22 | set(h.push_add,'Enable','on') 23 | 24 | set(h.menu_script,'Enable','on') 25 | 26 | %% 27 | clearvars -except h 28 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/drop_server_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function h = drop_server_pinnacle_setupX(h) 2 | %% 3 | set(h.push_add,'Enable','off') 4 | set(h.push_remove,'Enable','off') 5 | 6 | h = handlesoff_pinnacle_setupX(h,'institution'); 7 | h = handlesoff_pinnacle_setupX(h,'patient'); 8 | h = handlesoff_pinnacle_setupX(h,'plan'); 9 | h = handlesoff_pinnacle_setupX(h,'image'); 10 | h = handlesoff_pinnacle_setupX(h,'roi'); 11 | h = handlesoff_pinnacle_setupX(h,'dose'); 12 | 13 | axes_main_setupX(h) 14 | axes_minor1_setupX(h) 15 | axes_minor2_setupX(h) 16 | 17 | h.export = resetexport_pinnacle_setupX(h.export,'institution'); 18 | h.export = resetexport_pinnacle_setupX(h.export,'patient'); 19 | h.export = resetexport_pinnacle_setupX(h.export,'plan'); 20 | h.export = resetexport_pinnacle_setupX(h.export,'image'); 21 | h.export = resetexport_pinnacle_setupX(h.export,'roi'); 22 | h.export = resetexport_pinnacle_setupX(h.export,'dose'); 23 | 24 | contents = cellstr(get(h.drop_server,'String')); 25 | h.export.server_name = contents{get(h.drop_server,'Value')}; 26 | 27 | %Enables the connect button depending on the selection 28 | if strcmpi(h.export.server_name,'') 29 | set(h.push_server,'Enable','off') 30 | elseif strcmpi(h.export.server_name,'Local Pinnacle') 31 | h.export.server_user = 'username'; 32 | h.export.server_pass = 'password'; 33 | 34 | set(h.push_server,'Enable','on') 35 | h.export.remote = false; 36 | h.export.pinnacle = true; 37 | else 38 | set(h.push_server,'Enable','on') 39 | h.export.remote = true; 40 | h.export.pinnacle = true; 41 | end 42 | 43 | disp(['TREX-RT>> Server: ',h.export.server_name]); 44 | 45 | %% 46 | clearvars -except h 47 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/handlesoff_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = handlesoff_pinnacle_setupX(h,field) 2 | %% 3 | if strcmpi(field,'institution') 4 | set(h.drop_institution,'Enable','off') 5 | set(h.drop_institution,'String',{' '}) 6 | set(h.drop_institution,'Value',1); 7 | 8 | set(h.push_institution,'Enable','off') 9 | 10 | elseif strcmpi(field,'patient') 11 | h.filedata = []; 12 | 13 | set(h.drop_patient,'Enable','off') 14 | set(h.drop_patient,'String',{' '}) 15 | set(h.drop_patient,'Value',1) 16 | 17 | set(h.push_patient,'Enable','off') 18 | 19 | elseif strcmpi(field,'plan') 20 | set(h.drop_plan,'Enable','off') 21 | set(h.drop_plan,'String',{' '}) 22 | set(h.drop_plan,'Value',1) 23 | 24 | set(h.push_plan,'Enable','off') 25 | 26 | elseif strcmpi(field,'image') 27 | h.img = []; 28 | 29 | set(h.menu_displayscan,'Enable','off') 30 | 31 | set(h.slider_level,'Enable','off') 32 | set(h.text_window,'Enable','off') 33 | set(h.text_level,'Enable','off') 34 | set(h.edit_level,'Enable','off') 35 | set(h.edit_window,'Enable','off') 36 | set(h.text_preset,'Enable','off') 37 | set(h.drop_preset,'Enable','off') 38 | set(h.slider_window,'Enable','off') 39 | 40 | set(h.push_scaninfo,'Enable','off') 41 | set(h.menu_scaninfo,'Enable','off') 42 | 43 | elseif strcmpi(field,'roi') 44 | h.roi = []; 45 | h.roi.curvedata = []; 46 | h.roitoggle_curve = 0; 47 | 48 | set(h.drop_roi,'Enable','off') 49 | set(h.drop_roi,'String',{' '}) 50 | set(h.drop_roi,'Value',1) 51 | 52 | set(h.push_displaycurveroi,'Enable','off') 53 | set(h.push_displaycurveroi,'Value',0) 54 | set(h.menu_displaycurveroi,'Enable','off') 55 | set(h.menu_displaycurveroi,'Checked','off') 56 | 57 | set(h.menu_roiadvanced,'Enable','off') 58 | set(h.menu_roisubvolumes,'Enable','off') 59 | 60 | elseif strcmpi(field,'dose') 61 | h.dose = []; 62 | h.dosetoggle = 0; 63 | 64 | set(h.drop_dose,'Enable','off') 65 | set(h.drop_dose,'String',{' '}) 66 | set(h.drop_dose,'Value',1) 67 | 68 | set(h.push_doseinfo,'Enable','off') 69 | set(h.menu_doseinfo,'Enable','off') 70 | 71 | set(h.push_displaydose,'Enable','off') 72 | set(h.push_displaydose,'Value',0) 73 | set(h.menu_displaydose,'Enable','off') 74 | set(h.menu_displaydose,'Checked','off') 75 | 76 | end 77 | 78 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/interpDose_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [array] = interpDose_pinnacle_setupX(h) 2 | %% 3 | [Xq,Yq,Zq] = meshgrid(single(h.img.array_xV),... 4 | single(h.img.array_yV),... 5 | single(h.img.array_zV)); 6 | 7 | [X,Y,Z] = meshgrid(single(h.dose.array_xV),... 8 | single(h.dose.array_yV),... 9 | single(h.dose.array_zV)); 10 | 11 | disp('TREX-RT>> Interpolating dose array...') 12 | 13 | array = interp3(X,Y,Z,h.dose.array_original,Xq,Yq,Zq,'linear'); 14 | 15 | disp('TREX-RT>> Dose array interpolation complete!') 16 | 17 | %% 18 | clearvars -except array 19 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/pinnacle_setup_advanced/advanced_pinnacle_setupX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/setup/pinnacle_setupX/pinnacle_setup_advanced/advanced_pinnacle_setupX.fig -------------------------------------------------------------------------------- /setup/pinnacle_setupX/pinnacle_setup_advanced/axes_mask_advanced_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function axes_mask_advanced_pinnacle_setupX(h) 2 | %% 3 | cla(h.axes_mask) 4 | set(h.axes_mask,'Visible','on') 5 | set(h.axes_mask,'Color',[0,0,0]) 6 | set(h.axes_mask,'XTick',[]) 7 | set(h.axes_mask,'YTick',[]) 8 | 9 | img = sc(h.input.img.array(:,:,h.input.main_z),h.input.range); 10 | roi = sc(h.mask(:,:,h.input.main_z),[0 1]); 11 | 12 | display = img.*roi; 13 | 14 | if numel(display) == sum(display(:)) 15 | display = sc(zeros(size(h.input.img.array(:,:,h.input.main_z))),[0,1]); 16 | end 17 | 18 | h.main_scan = imshow(display,'DisplayRange',h.input.range,... 19 | 'Parent',h.axes_mask); 20 | 21 | axis(h.axes_mask,'square') 22 | 23 | %% 24 | clear 25 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/pinnacle_setup_script/add_10Gy_region_contours.m: -------------------------------------------------------------------------------- 1 | function [roi_name,roi_source,roi_int,roi_ext] = add_10Gy_region_contours(h) 2 | %% 3 | roi_name = cell(0); 4 | roi_source = cell(0); 5 | roi_int = cell(0); 6 | roi_ext = cell(0); 7 | 8 | if isempty(h.export.roi_source) 9 | msgbox('Select a source roi!') 10 | return 11 | end 12 | 13 | source = h.export.roi_source; 14 | 15 | %% 16 | iso_ind = regexpi(h.roi_namelist,'(\w*)00cGy'); 17 | 18 | if sum(cell2mat(iso_ind)) ~= 0 19 | iso_num = []; 20 | iso_str = cell(0); 21 | for i = 1:numel(iso_ind) 22 | if iso_ind{i} 23 | iso_num(end+1) = str2double(strrep(h.roi_namelist{i},'cGy','')); 24 | iso_str{end+1} = h.roi_namelist{i}; 25 | end 26 | end 27 | 28 | lines = 1000:1000:max(iso_num); 29 | 30 | for i = 1:numel(lines) 31 | t1 = num2str(lines(i)/100); 32 | 33 | roi_name{end+1,1} = [source,'_',t1,'Gy']; 34 | roi_source{end+1,1} = source; 35 | roi_int{end+1,1} = [num2str(lines(i)),'cGy']; 36 | roi_ext{end+1,1} = []; 37 | end 38 | end 39 | 40 | %% 41 | clearvars -except roi_name roi_source roi_int roi_ext 42 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/pinnacle_setup_script/add_10Gy_shell_contours.m: -------------------------------------------------------------------------------- 1 | function [roi_name,roi_source,roi_int,roi_ext] = add_10Gy_shell_contours(h) 2 | %% 3 | roi_name = cell(0); 4 | roi_source = cell(0); 5 | roi_int = cell(0); 6 | roi_ext = cell(0); 7 | 8 | if isempty(h.export.roi_source) 9 | msgbox('Select a source roi!') 10 | return 11 | end 12 | 13 | source = h.export.roi_source; 14 | 15 | %% 16 | iso_ind = regexpi(h.roi_namelist,'(\w*)00cGy'); 17 | 18 | if sum(cell2mat(iso_ind)) ~= 0 19 | iso_num = []; 20 | iso_str = cell(0); 21 | for i = 1:numel(iso_ind) 22 | if iso_ind{i} 23 | iso_num(end+1) = str2double(strrep(h.roi_namelist{i},'cGy','')); 24 | iso_str{end+1} = h.roi_namelist{i}; 25 | end 26 | end 27 | 28 | roi_name{end+1,1} = [source,'_0_5Gy']; 29 | roi_source{end+1,1} = source; 30 | roi_int{end+1,1} = '500cGy'; 31 | roi_ext{end+1,1} = []; 32 | 33 | lines = 500:1000:max(iso_num); 34 | 35 | for i = 2:numel(lines) 36 | t1 = num2str(lines(i-1)/100); 37 | t2 = num2str(lines(i)/100); 38 | 39 | roi_name{end+1,1} = [source,'_',t1,'_',t2,'Gy']; 40 | roi_source{end+1,1} = source; 41 | roi_int{end+1,1} = [num2str(lines(i)),'cGy']; 42 | roi_ext{end+1,1} = [num2str(lines(i-1)),'cGy']; 43 | end 44 | end 45 | 46 | %% 47 | clearvars -except roi_name roi_source roi_int roi_ext 48 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/pinnacle_setup_script/add_10Gy_shell_deformedcontours.m: -------------------------------------------------------------------------------- 1 | function [roi_name,roi_source,roi_int,roi_ext] = add_10Gy_shell_deformedcontours(h) 2 | %% 3 | roi_name = cell(0); 4 | roi_source = cell(0); 5 | roi_int = cell(0); 6 | roi_ext = cell(0); 7 | 8 | if isempty(h.export.roi_source) 9 | msgbox('Select a source roi!') 10 | return 11 | end 12 | 13 | source = h.export.roi_source; 14 | 15 | %% 16 | iso_ind = regexpi(h.roi_namelist,'^Deformed: (\w*)00cGy'); 17 | 18 | if sum(cell2mat(iso_ind)) ~= 0 19 | iso_num = []; 20 | iso_str = cell(0); 21 | for i = 1:numel(iso_ind) 22 | if iso_ind{i} 23 | iso_num(end+1) = str2double(strrep(strrep(h.roi_namelist{i},'cGy',''),'Deformed: ','')); 24 | iso_str{end+1} = h.roi_namelist{i}; 25 | end 26 | end 27 | 28 | roi_name{end+1,1} = [source,'_0_5Gy']; 29 | roi_source{end+1,1} = source; 30 | roi_int{end+1,1} = 'Deformed: 500cGy'; 31 | roi_ext{end+1,1} = []; 32 | 33 | lines = 500:1000:max(iso_num); 34 | 35 | for i = 2:numel(lines) 36 | t1 = num2str(lines(i-1)/100); 37 | t2 = num2str(lines(i)/100); 38 | 39 | roi_name{end+1,1} = [source,'_',t1,'_',t2,'Gy']; 40 | roi_source{end+1,1} = source; 41 | roi_int{end+1,1} = ['Deformed: ',num2str(lines(i)),'cGy']; 42 | roi_ext{end+1,1} = ['Deformed: ',num2str(lines(i-1)),'cGy']; 43 | end 44 | end 45 | 46 | %% 47 | clearvars -except roi_name roi_source roi_int roi_ext 48 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/pinnacle_setup_script/add_10Gy_shell_dose.m: -------------------------------------------------------------------------------- 1 | function [roi_name,roi_source,roi_int,roi_ext] = add_10Gy_shell_dose(h) 2 | %% 3 | roi_name = cell(0); 4 | roi_source = cell(0); 5 | roi_int = cell(0); 6 | roi_ext = cell(0); 7 | 8 | if isempty(h.export.roi_source) 9 | msgbox('Select a source roi!') 10 | return 11 | end 12 | 13 | if isempty(h.dose) || isempty(h.export.dose_name) 14 | msgbox('Select the dose trial!') 15 | return 16 | end 17 | 18 | source = h.export.roi_source; 19 | 20 | %% 21 | max_iso = round(max(h.dose.array_original(:))/100)*100; 22 | 23 | roi_name{end+1,1} = [source,'_0_5Gy']; 24 | roi_source{end+1,1} = source; 25 | roi_int{end+1,1} = ['500cGy (',h.export.dose_name,')']; 26 | roi_ext{end+1,1} = []; 27 | 28 | lines = 500:1000:max_iso; 29 | 30 | for i = 2:numel(lines) 31 | 32 | t1 = num2str(lines(i-1)/100); 33 | t2 = num2str(lines(i)/100); 34 | 35 | roi_name{end+1,1} = [source,'_',t1,'_',t2,'Gy']; 36 | roi_source{end+1,1} = source; 37 | roi_int{end+1,1} = [num2str(lines(i-1)),'cGy (',h.export.dose_name,')/',num2str(lines(i)),'cGy (',h.export.dose_name,')']; 38 | roi_ext{end+1,1} = []; 39 | 40 | end 41 | 42 | %% 43 | clearvars -except roi_name roi_source roi_int roi_ext 44 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/pinnacle_setup_script/add_all_contours.m: -------------------------------------------------------------------------------- 1 | function [roi_name,roi_source,roi_int,roi_ext] = add_all_contours(h) 2 | %% 3 | roi_name = cell(0); 4 | roi_source = cell(0); 5 | roi_int = cell(0); 6 | roi_ext = cell(0); 7 | 8 | for i = 1:numel(h.roi_namelist) 9 | roi_name{end+1,1} = h.roi_namelist{i}; 10 | roi_source{end+1,1} = h.roi_namelist{i}; 11 | roi_int{end+1,1} = []; 12 | roi_ext{end+1,1} = []; 13 | end 14 | 15 | %% 16 | clearvars -except roi_name roi_source roi_int roi_ext 17 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/push_add_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = push_add_pinnacle_setupX(h) 2 | %% 3 | for i = 1:size(h.tableHeadings,1) 4 | if i == 1 %adds a new row to the roi table data 5 | h.data{size(h.data,1)+1,i} = h.export.(h.tableHeadings{i,2}); 6 | else 7 | h.data{size(h.data,1),i} = h.export.(h.tableHeadings{i,2}); 8 | end 9 | end 10 | 11 | set(h.table_data,'Data',h.data); 12 | 13 | sNames = fieldnames(h.setupWrite); 14 | for i = 1:numel(sNames) 15 | if ischar(h.export.(sNames{i})) || isempty(h.export.(sNames{i})) 16 | h.setupWrite.(sNames{i}){end+1,1} = h.export.(sNames{i}); 17 | elseif iscell(h.export.(sNames{i})) 18 | h.setupWrite.(sNames{i}){end+1,1} = h.export.(sNames{i}){1}; 19 | else 20 | h.setupWrite.(sNames{i})(end+1,1) = h.export.(sNames{i}); 21 | end 22 | end 23 | 24 | disp(['TREX-RT>> New entry added: Name(',h.export.roi_name,... 25 | ') Source(',h.export.roi_source,') Avoid Int(',h.export.roi_int,... 26 | ') Avoid Ext(',h.export.roi_ext,')']); 27 | 28 | %% 29 | clearvars -except h 30 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/push_patient_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = push_patient_pinnacle_setupX(h) 2 | %% 3 | h = suspendhandles_pinnacle_setupX(h); 4 | 5 | disp('TREX-RT>> Patient selected!'); 6 | disp(['TREX-RT>> Patient Directory: ',h.export.patient_path]); 7 | 8 | %Get the list of plans and initialize 9 | if h.export.remote 10 | list = dir(h.ftp,h.export.patient_path); 11 | else 12 | list = dir(h.export.patient_path); 13 | end 14 | 15 | h.plan_pathlist = cell(0); 16 | h.plan_dirlist = cell(0); 17 | h.plan_idlist = cell(0); 18 | h.plan_namelist = cell(0); 19 | 20 | disp('TREX-RT>> Getting available plan names...'); 21 | 22 | %Cycle through each file/directory in the patient directory... 23 | for i = 1:numel(list) 24 | %...stop if it is one of the plans 25 | if ~isempty(regexpi(list(i).name,'^Plan_[0-9]')) && list(i).isdir 26 | if h.export.remote 27 | h.plan_pathlist{end+1,1} = [h.export.patient_path,'/',list(i).name,'/']; 28 | else 29 | h.plan_pathlist{end+1,1} = fullfile(h.export.patient_path,list(i).name); 30 | end 31 | h.plan_dirlist{end+1,1} = list(i).name; 32 | h.plan_idlist{end+1,1} = list(i).name(6:end); 33 | end 34 | end 35 | clear list 36 | 37 | h.filedata.plandata = splitParserX(h.filedata.patient,'Plan '); 38 | 39 | for i = 1:numel(h.plan_dirlist) 40 | for cellInd = 1:numel(h.filedata.plandata) 41 | planid = textParserX(h.filedata.plandata{cellInd},'PlanID '); 42 | 43 | if strcmpi(h.plan_idlist{i},planid) 44 | h.plan_namelist{end+1,1} = textParserX(h.filedata.plandata{cellInd},'PlanName '); 45 | break 46 | end 47 | clear planid 48 | end 49 | end 50 | 51 | disp(['TREX-RT>> Detected ',num2str(numel(h.plan_dirlist)),' unique plans!']); 52 | 53 | restorehandles_pinnacle_setupX(h) 54 | 55 | if numel(h.plan_dirlist) > 0 56 | h.plan_stringlist = strcat(h.plan_dirlist,repmat({': '},numel(h.plan_dirlist),1),h.plan_namelist); 57 | 58 | set(h.drop_plan,'Enable','on') 59 | set(h.drop_plan,'String',h.plan_stringlist) 60 | 61 | disp('TREX-RT>> Plan drop down menu populated. Please select an plan.'); 62 | else 63 | disp('TREX-RT>> No available plan data. Please select a different server/username/institution/plan.'); 64 | msgbox('No available plan data. Please select a different server/username/institution/plan.','Warning: SetupX','error'); 65 | end 66 | 67 | h.filedata = rmfield(h.filedata,'patient'); 68 | 69 | %% 70 | clearvars -except h 71 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/readImg_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [img] = readImg_pinnacle_setupX(h) 2 | %% 3 | disp('TREX-RT>> Reading image...') 4 | 5 | if h.export.remote 6 | cd(h.ftp,h.export.patient_path); 7 | drawnow; pause(0.1); 8 | img_file = mget(h.ftp,[h.export.image_name,'.img'],h.export.project_path); 9 | img_file = img_file{1}; 10 | cd(h.ftp,h.export.home_path); 11 | else 12 | copyfile(fullfile(h.export.patient_path,[h.export.image_name,'.img']),h.export.project_path); 13 | img_file = fullfile(h.export.project_path,[h.export.image_name,'.img']); 14 | end 15 | 16 | img = zeros([h.export.image_ydim,h.export.image_xdim,h.export.image_zdim],'uint16'); 17 | 18 | if ~h.export.image_byteorder 19 | byte_order = 'l'; 20 | else 21 | byte_order = 'b'; 22 | end 23 | 24 | fid = fopen(img_file); 25 | for i=1:h.export.image_zdim 26 | img(:,:,i) = reshape(fread(fid,h.export.image_xdim*h.export.image_ydim,'uint16',byte_order),h.export.image_ydim,h.export.image_xdim)'; 27 | end 28 | fclose(fid); 29 | 30 | delete(img_file) 31 | 32 | %% 33 | clearvars -except img 34 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/readROI_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = readROI_pinnacle_setupX(h) 2 | %% 3 | disp('TREX-RT>> Extracting ROI curve data...'); 4 | 5 | for cellInd = 1:numel(h.roi.data) 6 | name = textParserX(h.roi.data{cellInd},'name'); 7 | if strcmpi(h.export.roi_name,name) 8 | break 9 | end 10 | end 11 | 12 | curveCell = splitParserX(h.roi.data{cellInd},'points={'); 13 | 14 | h.roi.curvedata = cell(numel(curveCell),1); 15 | 16 | for i = 1:numel(curveCell) 17 | endjunk = splitParserX(curveCell{i},'End of points'); 18 | tempCurve = curveCell{i}(2:numel(curveCell{i})-numel(endjunk{1})); 19 | clear endjunk 20 | 21 | for j = 1:numel(tempCurve) 22 | points = cell2mat(textscan(tempCurve{j},'%f %f %f')); 23 | h.roi.curvedata{i}(j,:) = points; 24 | clear points 25 | end 26 | clear tempCurve 27 | end 28 | clear curveCell 29 | 30 | emp = []; 31 | for i = 1:numel(h.roi.curvedata) 32 | if isempty(h.roi.curvedata{i}) 33 | emp(end+1) = i; 34 | end 35 | end 36 | h.roi.curvedata(emp) = []; 37 | 38 | disp(['TREX-RT>> Extracted ROI data for ', num2str(length(h.roi.curvedata)),' curves!']); 39 | 40 | %% 41 | clearvars -except h 42 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/restorehandles_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function restorehandles_pinnacle_setupX(h) 2 | %% 3 | for i = 1:numel(h.h_names) 4 | set(h.(h.h_names{i}),'Enable',h.suspend.(h.h_names{i})); 5 | end 6 | 7 | drawnow; pause(0.001); 8 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/scaleCurvedata_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = scaleCurvedata_pinnacle_setupX(h) 2 | %% 3 | start_rngx = [h.img.array_xV(1),h.img.array_xV(end)]; 4 | rngx = [1,h.export.image_xdim]; 5 | 6 | start_rngy = [h.img.array_yV(1),h.img.array_yV(end)]; 7 | rngy = [1,h.export.image_ydim]; 8 | 9 | start_rngz = [h.img.array_zV(1),h.img.array_zV(end)]; 10 | rngz = [1,h.export.image_zdim]; 11 | 12 | h.roi.x = []; 13 | h.roi.y = []; 14 | h.roi.z = []; 15 | 16 | for cCount = 1:numel(h.roi.curvedata) 17 | tempx = rngx(1)+((rngx(2)-rngx(1))*(h.roi.curvedata{cCount}(:,1)-start_rngx(1)))./... 18 | (start_rngx(2)-start_rngx(1)); 19 | 20 | tempy = rngy(1)+((rngy(2)-rngy(1))*(h.roi.curvedata{cCount}(:,2)-start_rngy(1)))./... 21 | (start_rngy(2)-start_rngy(1)); 22 | 23 | tempz = rngz(1)+((rngz(2)-rngz(1))*(h.roi.curvedata{cCount}(:,3)-start_rngz(1)))./... 24 | (start_rngz(2)-start_rngz(1)); 25 | 26 | h.roi.x = [h.roi.x; tempx]; 27 | h.roi.y = [h.roi.y; tempy]; 28 | h.roi.z = [h.roi.z; tempz]; 29 | end 30 | 31 | %% 32 | clearvars -except h 33 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/subvolumes_pinnacle_setupX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/setup/pinnacle_setupX/subvolumes_pinnacle_setupX.fig -------------------------------------------------------------------------------- /setup/pinnacle_setupX/suspendhandles_pinnacle_setupX.m: -------------------------------------------------------------------------------- 1 | function [h] = suspendhandles_pinnacle_setupX(h) 2 | %% 3 | h.suspend = []; 4 | for i = 1:numel(h.h_names) 5 | h.suspend.(h.h_names{i}) = get(h.(h.h_names{i}),'Enable'); 6 | set(h.(h.h_names{i}),'Enable','off'); 7 | end 8 | 9 | drawnow; pause(0.001); 10 | 11 | %% 12 | clearvars -except h 13 | -------------------------------------------------------------------------------- /setup/pinnacle_setupX/view_doseinfo_pinnacle_setupX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/setup/pinnacle_setupX/view_doseinfo_pinnacle_setupX.fig -------------------------------------------------------------------------------- /setup/pinnacle_setupX/view_scaninfo_pinnacle_setupX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/setup/pinnacle_setupX/view_scaninfo_pinnacle_setupX.fig -------------------------------------------------------------------------------- /setup/read_setupX.m: -------------------------------------------------------------------------------- 1 | function [setupRead] = read_setupX(project_path,varargin) 2 | 3 | disp_flag = true; 4 | 5 | if nargin > 1 6 | disp_flag = varargin{1}; 7 | if ~islogical(disp_flag) 8 | error('I should really validate attributes...') 9 | end 10 | end 11 | 12 | %% 13 | setupRead = []; 14 | 15 | try 16 | files = dir(fullfile(project_path,'Log')); 17 | 18 | %Find the most current _setupX file 19 | date = 0; 20 | for i = 1:numel(files) 21 | if ~isempty(regexpi(files(i).name,'_setupX.mat$')) 22 | filedate = str2double(files(i).name(1:14)); 23 | 24 | if filedate > date 25 | date = filedate; 26 | end 27 | end 28 | end 29 | 30 | setupRead = load(fullfile(project_path,'Log',[num2str(date),'_setupX.mat'])); 31 | if disp_flag 32 | disp(['TREX-RT>> Importing setupX data: ',num2str(date),'_setupX.mat']); 33 | end 34 | 35 | catch err 36 | 37 | end 38 | 39 | %% 40 | clearvars -except setupRead 41 | -------------------------------------------------------------------------------- /setup/save_setupX.m: -------------------------------------------------------------------------------- 1 | function save_setupX(h) 2 | %% 3 | disp('TREX-RT>> Saving setupX.mat data...'); 4 | 5 | setupWrite = h.setupWrite; 6 | 7 | filename = [h.now,'_setupX.mat']; 8 | save(fullfile(h.export.project_path,'Log',filename),'-struct','setupWrite') 9 | 10 | %% 11 | remove_doseX(h.export.project_path) 12 | 13 | %% 14 | remove_textureX(h.export.project_path) 15 | 16 | %% 17 | disp(['TREX-RT>> setupX.mat saved to project log directory: ',filename]); 18 | 19 | %% 20 | clearvars 21 | -------------------------------------------------------------------------------- /texture/Texture Parameter Profiles/parameters_8bitonly.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,on 2 | hist,preprocess,None 3 | hist,preprocess,Gradient2D_sobel 4 | hist,preprocess,Gradient3D_Filter_sobel 5 | hist,preprocess,Local_Entropy_Filter_3 6 | hist,preprocess,Local_Range_Filter_3 7 | hist,preprocess,Local_STD_Filter_3 8 | hist,preprocess,LoG_Filter_10_2 9 | hist,preprocess,LoG_Filter_12_2p5 10 | hist,preprocess,LoG_Filter_4_1 11 | hist,preprocess,LoG_Filter_6_1p5 12 | hist,preprocess,LoG_Filter_8_1p8 13 | hist,preprocess,Threshold_1000 14 | hist,preprocess,Threshold_250 15 | hist,preprocess,Threshold_500 16 | hist,preprocess,Threshold_750 17 | shape,toggle,on 18 | glcm,toggle,on 19 | glcm,preprocess,None 20 | glcm,bd,8 21 | glcm,gl,[0 4095] 22 | glcm,dim,2D 23 | glcm,dim,3D 24 | glcm,offset,[1 0 0] 25 | glcm,offset,[0 1 0] 26 | glcm,offset,[0 0 1] 27 | glcm,offset,[1 1 0] 28 | glcm,offset,[-1 1 0] 29 | glcm,offset,[0 1 1] 30 | glcm,offset,[0 1 -1] 31 | glcm,offset,[1 0 1] 32 | glcm,offset,[1 0 -1] 33 | glcm,offset,[1 1 1] 34 | glcm,offset,[-1 1 1] 35 | glcm,offset,[1 1 -1] 36 | glcm,offset,[-1 1 -1] 37 | glcm,dist,1 38 | glcm,dist,3 39 | glcm,dist,5 40 | glrlm,toggle,on 41 | glrlm,preprocess,None 42 | glrlm,bd,8 43 | glrlm,gl,[0 4095] 44 | glrlm,dim,2D 45 | glrlm,dim,3D 46 | glrlm,offset,[1 0 0] 47 | glrlm,offset,[0 1 0] 48 | glrlm,offset,[0 0 1] 49 | glrlm,offset,[1 1 0] 50 | glrlm,offset,[-1 1 0] 51 | glrlm,offset,[0 1 1] 52 | glrlm,offset,[0 1 -1] 53 | glrlm,offset,[1 0 1] 54 | glrlm,offset,[1 0 -1] 55 | glrlm,offset,[1 1 1] 56 | glrlm,offset,[-1 1 1] 57 | glrlm,offset,[1 1 -1] 58 | glrlm,offset,[-1 1 -1] 59 | ngtdm,toggle,on 60 | ngtdm,preprocess,None 61 | ngtdm,bd,8 62 | ngtdm,gl,[0 4095] 63 | ngtdm,dim,2D 64 | ngtdm,dim,3D 65 | ngtdm,dist,1 66 | laws2D,toggle,on 67 | laws2D,preprocess,None 68 | -------------------------------------------------------------------------------- /texture/Texture Parameter Profiles/parameters_default.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,on 2 | hist,preprocess,None 3 | hist,preprocess,Gradient2D_sobel 4 | hist,preprocess,Gradient3D_Filter_sobel 5 | hist,preprocess,Local_Entropy_Filter_3 6 | hist,preprocess,Local_Range_Filter_3 7 | hist,preprocess,Local_STD_Filter_3 8 | hist,preprocess,LoG_Filter_10_2 9 | hist,preprocess,LoG_Filter_12_2p5 10 | hist,preprocess,LoG_Filter_4_1 11 | hist,preprocess,LoG_Filter_6_1p5 12 | hist,preprocess,LoG_Filter_8_1p8 13 | hist,preprocess,Threshold_1000 14 | hist,preprocess,Threshold_250 15 | hist,preprocess,Threshold_500 16 | hist,preprocess,Threshold_750 17 | glcm,toggle,on 18 | glcm,preprocess,None 19 | glcm,bd,4 20 | glcm,bd,5 21 | glcm,bd,6 22 | glcm,bd,7 23 | glcm,bd,8 24 | glcm,gl,[0 4095] 25 | glcm,dim,2D 26 | glcm,dim,3D 27 | glcm,offset,[1 0 0] 28 | glcm,offset,[0 1 0] 29 | glcm,offset,[0 0 1] 30 | glcm,offset,[1 1 0] 31 | glcm,offset,[-1 1 0] 32 | glcm,offset,[0 1 1] 33 | glcm,offset,[0 1 -1] 34 | glcm,offset,[1 0 1] 35 | glcm,offset,[1 0 -1] 36 | glcm,offset,[1 1 1] 37 | glcm,offset,[-1 1 1] 38 | glcm,offset,[1 1 -1] 39 | glcm,offset,[-1 1 -1] 40 | glcm,dist,1 41 | glcm,dist,3 42 | glcm,dist,5 43 | glrlm,toggle,on 44 | glrlm,preprocess,None 45 | glrlm,bd,4 46 | glrlm,bd,5 47 | glrlm,bd,6 48 | glrlm,bd,7 49 | glrlm,bd,8 50 | glrlm,gl,[0 4095] 51 | glrlm,dim,2D 52 | glrlm,dim,3D 53 | glrlm,offset,[1 0 0] 54 | glrlm,offset,[0 1 0] 55 | glrlm,offset,[0 0 1] 56 | glrlm,offset,[1 1 0] 57 | glrlm,offset,[-1 1 0] 58 | glrlm,offset,[0 1 1] 59 | glrlm,offset,[0 1 -1] 60 | glrlm,offset,[1 0 1] 61 | glrlm,offset,[1 0 -1] 62 | glrlm,offset,[1 1 1] 63 | glrlm,offset,[-1 1 1] 64 | glrlm,offset,[1 1 -1] 65 | glrlm,offset,[-1 1 -1] 66 | ngtdm,toggle,on 67 | ngtdm,preprocess,None 68 | ngtdm,bd,4 69 | ngtdm,bd,5 70 | ngtdm,bd,6 71 | ngtdm,bd,7 72 | ngtdm,bd,8 73 | ngtdm,gl,[0 4095] 74 | ngtdm,dim,2D 75 | ngtdm,dim,3D 76 | ngtdm,dist,1 77 | laws2D,toggle,on 78 | laws2D,preprocess,None 79 | lung,toggle,on 80 | lung,preprocess,None 81 | -------------------------------------------------------------------------------- /texture/Texture Parameter Profiles/parameters_shape_only.trex: -------------------------------------------------------------------------------- 1 | hist,toggle,off 2 | hist,preprocess,None 3 | hist,preprocess,Gradient2D_sobel 4 | hist,preprocess,Gradient3D_Filter_sobel 5 | hist,preprocess,Local_Entropy_Filter_3 6 | hist,preprocess,Local_Range_Filter_3 7 | hist,preprocess,Local_STD_Filter_3 8 | hist,preprocess,LoG_Filter_10_2 9 | hist,preprocess,LoG_Filter_12_2p5 10 | hist,preprocess,LoG_Filter_4_1 11 | hist,preprocess,LoG_Filter_6_1p5 12 | hist,preprocess,LoG_Filter_8_1p8 13 | hist,preprocess,Threshold_1000 14 | hist,preprocess,Threshold_250 15 | hist,preprocess,Threshold_500 16 | hist,preprocess,Threshold_750 17 | glcm,toggle,off 18 | glcm,preprocess,None 19 | glcm,bd,4 20 | glcm,bd,5 21 | glcm,bd,6 22 | glcm,bd,7 23 | glcm,bd,8 24 | glcm,gl,[0 4095] 25 | glcm,dim,2D 26 | glcm,dim,3D 27 | glcm,offset,[1 0 0] 28 | glcm,offset,[0 1 0] 29 | glcm,offset,[0 0 1] 30 | glcm,offset,[1 1 0] 31 | glcm,offset,[-1 1 0] 32 | glcm,offset,[0 1 1] 33 | glcm,offset,[0 1 -1] 34 | glcm,offset,[1 0 1] 35 | glcm,offset,[1 0 -1] 36 | glcm,offset,[1 1 1] 37 | glcm,offset,[-1 1 1] 38 | glcm,offset,[1 1 -1] 39 | glcm,offset,[-1 1 -1] 40 | glcm,dist,1 41 | glcm,dist,3 42 | glcm,dist,5 43 | glrlm,toggle,off 44 | glrlm,preprocess,None 45 | glrlm,bd,4 46 | glrlm,bd,5 47 | glrlm,bd,6 48 | glrlm,bd,7 49 | glrlm,bd,8 50 | glrlm,gl,[0 4095] 51 | glrlm,dim,2D 52 | glrlm,dim,3D 53 | glrlm,offset,[1 0 0] 54 | glrlm,offset,[0 1 0] 55 | glrlm,offset,[0 0 1] 56 | glrlm,offset,[1 1 0] 57 | glrlm,offset,[-1 1 0] 58 | glrlm,offset,[0 1 1] 59 | glrlm,offset,[0 1 -1] 60 | glrlm,offset,[1 0 1] 61 | glrlm,offset,[1 0 -1] 62 | glrlm,offset,[1 1 1] 63 | glrlm,offset,[-1 1 1] 64 | glrlm,offset,[1 1 -1] 65 | glrlm,offset,[-1 1 -1] 66 | ngtdm,toggle,off 67 | ngtdm,preprocess,None 68 | ngtdm,bd,4 69 | ngtdm,bd,5 70 | ngtdm,bd,6 71 | ngtdm,bd,7 72 | ngtdm,bd,8 73 | ngtdm,gl,[0 4095] 74 | ngtdm,dim,2D 75 | ngtdm,dim,3D 76 | ngtdm,dist,1 77 | laws2D,toggle,off 78 | laws2D,preprocess,None 79 | lung,toggle,off 80 | lung,preprocess,None 81 | shape,toggle,on 82 | -------------------------------------------------------------------------------- /texture/remove_textureX.m: -------------------------------------------------------------------------------- 1 | function remove_textureX(project_path) 2 | %% Remove each module.mat 3 | h = parameterfields_textureX(); 4 | for i = 1:numel(h.module_names) 5 | filename = [upper(h.module_names{i}),'.mat']; 6 | if exist(fullfile(project_path,filename),'file') == 2 7 | delete(fullfile(project_path,filename)) 8 | end 9 | end 10 | %% 11 | clearvars 12 | 13 | -------------------------------------------------------------------------------- /texture/start_textureX.m: -------------------------------------------------------------------------------- 1 | function [h] = start_textureX(h) 2 | %% 3 | set(h.push_start,'Enable','off') 4 | start = tic; 5 | 6 | remove_textureX(h.project_path) 7 | 8 | disp('TREX-RT>> Texture data extraction started...') 9 | 10 | %% Run each module 11 | for i = 1:numel(h.module_names) 12 | module = h.module_names{i}; 13 | if strcmpi(h.(module).toggle,'on') 14 | [h] = startmodule_textureX(h,module); 15 | end 16 | pause(1) 17 | end 18 | 19 | %% 20 | set(h.text_wait2,'String','Texture extraction complete!') 21 | drawnow; pause(0.1); 22 | disp('TREX-RT>> Texture Data Extraction Complete!') 23 | disp(['TREX-RT>> Total TextureX run time: ',num2str(toc(start)),' seconds']) 24 | 25 | %% 26 | clearvars -except h hObject 27 | 28 | -------------------------------------------------------------------------------- /texture/tex_modules/tex_glcm/glcm_halveNL.m: -------------------------------------------------------------------------------- 1 | function [glcm_out] = glcm_halveNL(glcm) 2 | %GLCM_HALVENL Reduce number of gray levels in glcm by factor of 2 3 | % [GLCM] = GLCM_HALVENL(GLCM) combines neighboring rows and columns of 4 | % glcm to achieve reduced bit depth glcm 5 | % 6 | % GLCM can be an m x n x p array of valid gray-level co-occurrence 7 | % matrices. 8 | % 9 | % Notes 10 | % ----- 11 | % 12 | % Class Support 13 | % ------------- 14 | % GLCM can be log2ical or numeric, and it must contain real, non-negative, finite, 15 | % integers. 16 | % 17 | % Examples 18 | % -------- 19 | % GLCM = [0 1 2 3;1 1 2 3;1 0 2 0;0 0 0 3]; 20 | % GLCM = glcm_halveNL(GLCM) 21 | % 22 | % See also GLCM_MATRIX3D. 23 | % 24 | % References 25 | % ---------- 26 | % 27 | % $SPK 28 | 29 | %% 30 | numGLCM = size(glcm,3); 31 | glcm_out = nan(size(glcm,1)/2,size(glcm,2)/2,size(glcm,3)); 32 | 33 | for k = 1:numGLCM 34 | 35 | glcm_r1 = glcm(1:2:end,:,k); 36 | glcm_r2 = glcm(2:2:end,:,k); 37 | 38 | glcm_r = glcm_r1+glcm_r2; 39 | 40 | glcm_c1 = glcm_r(:,1:2:end); 41 | glcm_c2 = glcm_r(:,2:2:end); 42 | 43 | glcm_out(:,:,k) = glcm_c1+glcm_c2; 44 | end 45 | 46 | %% 47 | clearvars -except glcm_out 48 | -------------------------------------------------------------------------------- /texture/tex_modules/tex_hist/hist_textureX.m: -------------------------------------------------------------------------------- 1 | function [test_missing] = hist_textureX(extractRead_entry,test_missing) 2 | %% Do some preallocation... 3 | num_missing = numel(test_missing.module); 4 | 5 | stats = hist_features(1); 6 | featureNames = fieldnames(stats); 7 | for nameCount = 1:length(featureNames) 8 | test_missing.(['feature_',featureNames{nameCount}]) = nan(num_missing,1); 9 | end 10 | 11 | %% Load the data, do some sanity checks of the passed data first 12 | project_patient = unique(extractRead_entry.project_patient); 13 | image_file = unique(extractRead_entry.image_file); 14 | roi_file = unique(extractRead_entry.roi_file); 15 | if numel(project_patient) == 1 && numel(image_file) == 1 && numel(roi_file) == 1 16 | project_patient = project_patient{1}; 17 | image_file = image_file{1}; 18 | roi_file = roi_file{1}; 19 | else 20 | error('All of the data in extractRead_entry should have the same project_patient, image_file, and roi_file') 21 | end 22 | 23 | img = load(fullfile(project_patient,image_file),'array'); 24 | img = img.array; 25 | 26 | mask = load(fullfile(project_patient,roi_file),'mask'); 27 | mask = mask.mask; 28 | 29 | preprocess = unique(test_missing.parameter_preprocess); 30 | 31 | %% -----Preprocess Loop----- 32 | for count_preprocess = 1:length(preprocess) %Start loop over each preprocess... 33 | %Start with each preprocess so we don't have to do this 34 | %preprocessing/preprocessing every time...helps speed things up, especially 35 | %in the instances where the applied preprocess takes awhile. 36 | 37 | %Prep the data to get the image I that will be passed into the analysis 38 | %routines 39 | [I,current_preprocess] = prepCT(img,mask,'preprocess',preprocess{count_preprocess}); 40 | 41 | ind_preprocess = strcmpi(test_missing.parameter_preprocess,current_preprocess); %logical index for current preprocess 42 | 43 | %Print to the command window... 44 | disp(['TREX-RT>> Preprocess (',current_preprocess,')']); 45 | 46 | %Calculate the histogram stats 47 | stats = hist_features(I); 48 | 49 | %Write stats to test_missing 50 | for nameCount = 1:length(featureNames) 51 | test_missing.(['feature_',featureNames{nameCount}])(ind_preprocess) = stats.(featureNames{nameCount}); 52 | end 53 | end %end loop over each preprocess 54 | 55 | %% 56 | clearvars -except test_missing 57 | -------------------------------------------------------------------------------- /texture/tex_modules/tex_laws2D/laws2D_textureX.m: -------------------------------------------------------------------------------- 1 | function [test_missing] = laws2D_textureX(extractRead_entry,test_missing) 2 | %% Do some preallocation... 3 | num_missing = numel(test_missing.module); 4 | 5 | stats = laws2D_features(1); 6 | featureNames = fieldnames(stats); 7 | for nameCount = 1:length(featureNames) 8 | test_missing.(['feature_',featureNames{nameCount}]) = nan(num_missing,1); 9 | end 10 | 11 | %% Load the data, do some sanity checks of the passed data first 12 | project_patient = unique(extractRead_entry.project_patient); 13 | image_file = unique(extractRead_entry.image_file); 14 | roi_file = unique(extractRead_entry.roi_file); 15 | if numel(project_patient) == 1 && numel(image_file) == 1 && numel(roi_file) == 1 16 | project_patient = project_patient{1}; 17 | image_file = image_file{1}; 18 | roi_file = roi_file{1}; 19 | else 20 | error('All of the data in extractRead_entry should have the same project_patient, image_file, and roi_file') 21 | end 22 | 23 | img = load(fullfile(project_patient,image_file),'array'); 24 | img = img.array; 25 | 26 | mask = load(fullfile(project_patient,roi_file),'mask'); 27 | mask = mask.mask; 28 | 29 | preprocess = unique(test_missing.parameter_preprocess); 30 | 31 | %% -----Preprocess Loop----- 32 | for count_preprocess = 1:length(preprocess) %Start loop over each preprocess... 33 | %Start with each preprocess so we don't have to do this 34 | %preprocessing/preprocessing every time...helps speed things up, especially 35 | %in the instances where the applied preprocess takes awhile. 36 | 37 | %Prep the data to get the image I that will be passed into the analysis 38 | %routines 39 | [~,current_preprocess,mask,I_crop] = prepCT(img,mask,'preprocess',preprocess{count_preprocess}); 40 | 41 | ind_preprocess = strcmpi(test_missing.parameter_preprocess,current_preprocess); %logical index for current preprocess 42 | ind = find(ind_preprocess); %Numerical index for loop 43 | 44 | for i = 1:length(ind) %Loop through each parameter combination 45 | %Print to the command window... 46 | disp(['TREX-RT>> Preprocess (',current_preprocess,')']); 47 | 48 | stats = laws2D_features(I_crop,mask); 49 | 50 | %Write stats 51 | for nameCount = 1:length(featureNames) 52 | test_missing.(['feature_',featureNames{nameCount}])(ind(i)) = stats.(featureNames{nameCount}); 53 | end 54 | end 55 | end %end loop over each preprocess 56 | 57 | %% 58 | clearvars -except test_missing 59 | -------------------------------------------------------------------------------- /texture/tex_modules/tex_shape/shape_features.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/texture/tex_modules/tex_shape/shape_features.m -------------------------------------------------------------------------------- /texture/tex_modules/tex_shape/shape_textureX.m: -------------------------------------------------------------------------------- 1 | function [test_missing] = shape_textureX(extractRead_entry,test_missing) 2 | %% Do some preallocation... 3 | num_missing = numel(test_missing.module); 4 | 5 | stats = shape_features(true); 6 | featureNames = fieldnames(stats); 7 | for nameCount = 1:length(featureNames) 8 | test_missing.(['feature_',featureNames{nameCount}]) = nan(num_missing,1); 9 | end 10 | 11 | %% Load the data, do some sanity checks of the passed data first 12 | project_patient = unique(extractRead_entry.project_patient); 13 | image_file = unique(extractRead_entry.image_file); 14 | roi_file = unique(extractRead_entry.roi_file); 15 | if numel(project_patient) == 1 && numel(image_file) == 1 && numel(roi_file) == 1 16 | project_patient = project_patient{1}; 17 | image_file = image_file{1}; 18 | roi_file = roi_file{1}; 19 | else 20 | error('All of the data in extractRead_entry should have the same project_patient, image_file, and roi_file') 21 | end 22 | 23 | mask = load(fullfile(project_patient,roi_file),'mask'); 24 | mask = mask.mask; 25 | 26 | xV = load(fullfile(project_patient,image_file),'array_xV'); 27 | xV = xV.array_xV; 28 | yV = load(fullfile(project_patient,image_file),'array_yV'); 29 | yV = yV.array_yV; 30 | zV = load(fullfile(project_patient,image_file),'array_zV'); 31 | zV = zV.array_zV; 32 | 33 | %% Calculate the histogram stats 34 | stats = shape_features(mask,xV,yV,zV); 35 | 36 | %Write stats to test_missing 37 | for nameCount = 1:length(featureNames) 38 | test_missing.(['feature_',featureNames{nameCount}]) = stats.(featureNames{nameCount}); 39 | end 40 | 41 | %% 42 | clearvars -except test_missing 43 | -------------------------------------------------------------------------------- /texture/tex_parameters/profileread_textureX.m: -------------------------------------------------------------------------------- 1 | function [h] = profileread_textureX(h,profile) 2 | %% Read parameter profile list and sort into appropriate fields 3 | for i = 1:size(profile,1) 4 | module = profile{i,1}; 5 | parameter = profile{i,2}; 6 | 7 | if strcmpi(parameter,'toggle') 8 | h.(module).(parameter) = profile{i,3}; 9 | else 10 | h.(module).(parameter){end+1,1} = profile{i,3}; 11 | end 12 | end 13 | 14 | %% 15 | clearvars -except h 16 | -------------------------------------------------------------------------------- /texture/tex_parameters/profilewrite_textureX.m: -------------------------------------------------------------------------------- 1 | function [profile] = profilewrite_textureX(h) 2 | %%Write the texture parameter profile to a cell array. 3 | profile = cell(0); 4 | 5 | for i = 1:numel(h.module_names) 6 | module = h.module_names{i}; 7 | parameters = fieldnames(h.(module)); 8 | 9 | for j = 1:numel(parameters) 10 | if ischar(h.(module).(parameters{j})) 11 | profile{end+1,1} = module; 12 | profile{end,2} = parameters{j}; 13 | profile{end,3} = h.(module).(parameters{j}); 14 | 15 | else 16 | for k = 1:numel(h.(module).(parameters{j})) 17 | profile{end+1,1} = module; 18 | profile{end,2} = parameters{j}; 19 | profile{end,3} = h.(module).(parameters{j}){k}; 20 | end 21 | end 22 | end 23 | end 24 | 25 | %% 26 | clearvars -except profile 27 | -------------------------------------------------------------------------------- /texture/tex_prep/prepPreprocess.m: -------------------------------------------------------------------------------- 1 | function [img,preprocess] = prepPreprocess(varargin) 2 | %PREPPREPROCESS 3 | % [IMG,FILTER] = PREPPREPROCESS(IMG,PREPROCESS) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'preprocess' (Optional) This is the name of the preprocess to be applied 10 | % to the input image. See the switch statement below for 11 | % the available options. 12 | % 13 | % Notes 14 | % ----- 15 | % 16 | % $SPK 17 | 18 | %% 19 | [img,preprocess] = ParseInputs(varargin{:}); 20 | 21 | %% 22 | if strcmpi(preprocess,'none') 23 | 24 | else 25 | [~,func_names,preprocess_names] = read_preprocess; 26 | ind = strcmpi(preprocess,preprocess_names); 27 | if sum(ind)==0 28 | error('Input preprocess is invalid') 29 | end 30 | %fhandle = [func_names{ind,1},'(img)']; 31 | img = feval(func_names{ind,1},img); 32 | end 33 | 34 | %% 35 | clearvars -except img preprocess 36 | 37 | %-------------------------------------------------------------------------- 38 | function [img,preprocess] = ParseInputs(varargin) 39 | 40 | if verLessThan('matlab', '7.13') 41 | iptchecknargin(1,2,nargin,mfilename); 42 | else 43 | narginchk(1,2); 44 | end 45 | 46 | % Check img 47 | img = varargin{1}; 48 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 49 | if ndims(img) > 3 50 | error(message('images:PREPPREPROCESS:invalidSizeForIMG')) 51 | end 52 | 53 | % Assign Defaults 54 | preprocess = 'none'; 55 | 56 | % Parse Input Arguments 57 | if nargin ~= 1 58 | preprocess = varargin{2}; 59 | end 60 | 61 | %% 62 | clearvars -except img preprocess 63 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_addnoise.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_addnoise(varargin) 2 | %FILTER_ADDNOISE 3 | % [IMG,FILTER_NAME] = FILTER_ADDNOISE(IMG,NOISE_STD) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'noise_std' (Optional) 10 | % Default: 15 11 | % 12 | % Notes 13 | % ----- 14 | % 15 | % $SPK 16 | 17 | [img,noise_std] = ParseInputs(varargin{:}); 18 | 19 | J = round(img + noise_std.*randn(size(img))); 20 | 21 | filter_name = ['Add Noise (',num2str(noise_std),')']; 22 | 23 | %% 24 | clearvars -except J filter_name 25 | 26 | %-------------------------------------------------------------------------- 27 | function [img,noise_std] = ParseInputs(varargin) 28 | 29 | if verLessThan('matlab', '7.13') 30 | iptchecknargin(1,2,nargin,mfilename); 31 | else 32 | narginchk(1,2); 33 | end 34 | 35 | % Check img 36 | img = varargin{1}; 37 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 38 | if ndims(img) > 3 39 | error(message('images:filter:invalidSizeForIMG')) 40 | end 41 | 42 | % Assign Defaults 43 | noise_std = 15; 44 | 45 | % Parse Input Arguments 46 | if nargin ~= 1 47 | noise_std = varargin{2}; 48 | end 49 | 50 | %% 51 | clearvars -except img noise_std 52 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_adplocalnoise.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_adplocalnoise(varargin) 2 | %FILTER_ADPLOCALNOISE Perform adaptive local noise reduction filtering 3 | % [IMG,FILTER_NAME] = FILTER_ADPLOCALNOISE(IMG,SIZ,VARNOISE) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'siz' (Optional) 10 | % Default: 5 11 | % 12 | % 'varNoise' (Optional) 13 | % Default: 15 14 | % 15 | % Notes 16 | % ----- 17 | % 18 | % $SPK 19 | 20 | [img,siz,varNoise] = ParseInputs(varargin{:}); 21 | 22 | padSize = (siz-1)/2; 23 | 24 | padI = padarray(img,padSize); 25 | J = zeros(size(padI)); 26 | 27 | for i = padSize+1:size(padI,1)-padSize 28 | for j = padSize+1:size(padI,2)-padSize 29 | 30 | region = padI(i-padSize:i+padSize,j-padSize:j+padSize); 31 | 32 | meanLocal = mean(region(:)); 33 | varLocal = var(region(:)); 34 | 35 | J(i,j) = padI(i,j) - (varNoise/varLocal)*(padI(i,j) - meanLocal); 36 | end 37 | end 38 | 39 | J = J(padSize+1:size(J,1)-padSize,padSize+1:size(J,2)-padSize); 40 | 41 | filter_name = ['Adaptive Local Noise (',num2str(siz),'/',num2str(varNoise),')']; 42 | 43 | %% 44 | clearvars -except J filter_name 45 | 46 | %-------------------------------------------------------------------------- 47 | function [img,siz,varNoise] = ParseInputs(varargin) 48 | 49 | if verLessThan('matlab', '7.13') 50 | iptchecknargin(1,3,nargin,mfilename); 51 | else 52 | narginchk(1,3); 53 | end 54 | 55 | % Check img 56 | img = varargin{1}; 57 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 58 | if ndims(img) > 3 59 | error(message('images:filter:invalidSizeForIMG')) 60 | end 61 | 62 | % Assign Defaults 63 | siz = 5; 64 | varNoise = 15; 65 | 66 | % Parse Input Arguments 67 | if nargin ~= 1 68 | siz = varargin{2}; 69 | varNoise = varargin{3}; 70 | end 71 | 72 | %% 73 | clearvars -except img siz varNoise 74 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_alphatrim.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_alphatrim(varargin) 2 | %FILTER_ALPHATRIM Implements an alpha-trimed mean filter 3 | % [IMG,FILTER_NAME] = FILTER_ALPHATRIM(IMG,SIZ,D) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'siz' (Optional) 10 | % Default: 5 11 | % 12 | % 'd' (Optional) 13 | % Default: 15 14 | % 15 | % Notes 16 | % ----- 17 | % From Gonzalez and Woods 18 | % 19 | % $SPK 20 | 21 | [img,siz,d] = ParseInputs(varargin{:}); 22 | 23 | J = imfilter(img,ones(siz,siz),'symmetric'); 24 | for k = 1:d/2 25 | J = J-ordfilt2(img,k,ones(siz,siz),'symmetric'); 26 | end 27 | for k = (siz*siz-(d/2)+1):siz*siz 28 | J = J-ordfilt2(img,k,ones(siz,siz),'symmetric'); 29 | end 30 | J = J/(siz*siz-d); 31 | 32 | filter_name = ['Alpha Trimed Mean (',num2str(siz),'/',num2str(d),')']; 33 | 34 | %% 35 | clearvars -except J filter_name 36 | 37 | %-------------------------------------------------------------------------- 38 | function [img,siz,d] = ParseInputs(varargin) 39 | 40 | if verLessThan('matlab', '7.13') 41 | iptchecknargin(1,3,nargin,mfilename); 42 | else 43 | narginchk(1,3); 44 | end 45 | 46 | % Check img 47 | img = varargin{1}; 48 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 49 | if ndims(img) > 3 50 | error(message('images:filter:invalidSizeForIMG')) 51 | end 52 | 53 | % Assign Defaults 54 | siz = 5; 55 | d = 2; 56 | 57 | % Parse Input Arguments 58 | if nargin ~= 1 59 | siz = varargin{2}; 60 | d = varargin{3}; 61 | if (d<=0) || (d/2~=round(d/2)) 62 | error('d must be a positive, even integer') 63 | end 64 | end 65 | 66 | %% 67 | clearvars -except img siz d 68 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_ave.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_ave(varargin) 2 | %FILTER_AVE 3 | % [IMG,FILTER_NAME] = FILTER_AVE(IMG,HSIZE) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'hsize' (Optional) 10 | % Default: 5 11 | % 12 | % Notes 13 | % ----- 14 | % 15 | % $SPK 16 | 17 | [img,hsize] = ParseInputs(varargin{:}); 18 | 19 | h = fspecial('average',hsize); 20 | J = imfilter(img,h); 21 | 22 | filter_name = ['Average (',num2str(hsize),')']; 23 | 24 | %% 25 | clearvars -except J filter_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img,hsize] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,2,nargin,mfilename); 32 | else 33 | narginchk(1,2); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:filter:invalidSizeForIMG')) 41 | end 42 | 43 | % Assign Defaults 44 | hsize = 5; 45 | 46 | % Parse Input Arguments 47 | if nargin ~= 1 48 | hsize = varargin{2}; 49 | end 50 | 51 | %% 52 | clearvars -except img hsize 53 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_charmean.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_charmean(varargin) 2 | %FILTER_CHARMEAN Implements a contraharmonic mean filter 3 | % [IMG,FILTER_NAME] = FILTER_CHARMEAN(IMG,SIZ,Q) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'siz' (Optional) 10 | % Default: 5 11 | % 12 | % 'q' (Optional) 13 | % Default: 0.5 14 | % 15 | % Notes 16 | % ----- 17 | % From Gonzalez and Woods 18 | % 19 | % $SPK 20 | 21 | [img,siz,q] = ParseInputs(varargin{:}); 22 | 23 | J = imfilter(img.^(q+1),ones(siz,siz),'replicate'); 24 | J = J./(imfilter(img.^q,ones(siz,siz),'replicate')+eps); 25 | 26 | filter_name = ['Contraharmonic Mean (',num2str(siz),'/',num2str(q),')']; 27 | 28 | %% 29 | clearvars -except J filter_name 30 | 31 | %-------------------------------------------------------------------------- 32 | function [img,siz,q] = ParseInputs(varargin) 33 | 34 | if verLessThan('matlab', '7.13') 35 | iptchecknargin(1,3,nargin,mfilename); 36 | else 37 | narginchk(1,3); 38 | end 39 | 40 | % Check img 41 | img = varargin{1}; 42 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 43 | if ndims(img) > 3 44 | error(message('images:filter:invalidSizeForIMG')) 45 | end 46 | 47 | % Assign Defaults 48 | siz = 5; 49 | q = 0.5; 50 | 51 | % Parse Input Arguments 52 | if nargin ~= 1 53 | siz = varargin{2}; 54 | q = varargin{3}; 55 | end 56 | 57 | %% 58 | clearvars -except img siz q 59 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_gaussian.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_gaussian(varargin) 2 | %FILTER_GAUSSIAN 3 | % [IMG,FILTER_NAME] = FILTER_GAUSSIAN(IMG,HSIZE,SIGMA) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'hsize' (Optional) 10 | % Default: 3 11 | % 12 | % 'sigma' (Optional) 13 | % Default: 0.5 14 | % 15 | % Notes 16 | % ----- 17 | % 18 | % $SPK 19 | 20 | [img,hsize,sigma] = ParseInputs(varargin{:}); 21 | 22 | h = fspecial('gaussian',hsize,sigma); 23 | J = imfilter(img,h); 24 | 25 | filter_name = ['Gaussian (',num2str(hsize),'/',num2str(sigma),')']; 26 | 27 | %% 28 | clearvars -except J filter_name 29 | 30 | %-------------------------------------------------------------------------- 31 | function [img,hsize,sigma] = ParseInputs(varargin) 32 | 33 | if verLessThan('matlab', '7.13') 34 | iptchecknargin(1,3,nargin,mfilename); 35 | else 36 | narginchk(1,3); 37 | end 38 | 39 | % Check img 40 | img = varargin{1}; 41 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 42 | if ndims(img) > 3 43 | error(message('images:filter:invalidSizeForIMG')) 44 | end 45 | 46 | % Assign Defaults 47 | hsize = 3; 48 | sigma = 0.5; 49 | 50 | % Parse Input Arguments 51 | if nargin ~= 1 52 | hsize = varargin{2}; 53 | sigma = varargin{3}; 54 | end 55 | 56 | %% 57 | clearvars -except img hsize sigma 58 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_gmean.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_gmean(varargin) 2 | %FILTER_GMEAN Implements a gemometric mean filter 3 | % [IMG,FILTER_NAME] = FILTER_GMEAN(IMG,SIZ) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'siz' (Optional) 10 | % Default: 5 11 | % 12 | % Notes 13 | % ----- 14 | % From Gonzalez and Woods 15 | % 16 | % $SPK 17 | 18 | [img,siz] = ParseInputs(varargin{:}); 19 | 20 | J = exp(imfilter(log(img),ones(siz,siz),'replicate')).^(1/siz/siz); 21 | 22 | filter_name = ['Geometric Mean (',num2str(siz),')']; 23 | 24 | %% 25 | clearvars -except J filter_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img,siz] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,2,nargin,mfilename); 32 | else 33 | narginchk(1,2); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:filter:invalidSizeForIMG')) 41 | end 42 | 43 | % Assign Defaults 44 | siz = 5; 45 | 46 | % Parse Input Arguments 47 | if nargin ~= 1 48 | siz = varargin{2}; 49 | end 50 | 51 | %% 52 | clearvars -except img siz 53 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_harmean.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_harmean(varargin) 2 | %FILTER_HARMEAN Implements a harmonic mean filter 3 | % [IMG,FILTER_NAME] = FILTER_HARMEAN(IMG,SIZ) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'siz' (Optional) 10 | % Default: 5 11 | % 12 | % Notes 13 | % ----- 14 | % From Gonzalez and Woods 15 | % 16 | % $SPK 17 | 18 | [img,siz] = ParseInputs(varargin{:}); 19 | 20 | J = siz*siz./imfilter(1./(img+eps),ones(siz,siz),'replicate'); 21 | 22 | filter_name = ['Harmonic Mean (',num2str(siz),')']; 23 | 24 | %% 25 | clearvars -except J filter_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img,siz] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,2,nargin,mfilename); 32 | else 33 | narginchk(1,2); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:filter:invalidSizeForIMG')) 41 | end 42 | 43 | % Assign Defaults 44 | siz = 5; 45 | 46 | % Parse Input Arguments 47 | if nargin ~= 1 48 | siz = varargin{2}; 49 | end 50 | 51 | %% 52 | clearvars -except img siz 53 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_laplacian.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_laplacian(varargin) 2 | %FILTER_LAPLACIAN 3 | % [IMG,FILTER_NAME] = FILTER_LAPLACIAN(IMG,ALPHA) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'alpha' (Optional) 10 | % Default: 0.2 11 | % 12 | % Notes 13 | % ----- 14 | % 15 | % $SPK 16 | 17 | [img,alpha] = ParseInputs(varargin{:}); 18 | 19 | h = fspecial('laplacian',alpha); 20 | J = imfilter(img,h); 21 | 22 | filter_name = ['Laplacian (',num2str(alpha),')']; 23 | 24 | %% 25 | clearvars -except J filter_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img,alpha] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,2,nargin,mfilename); 32 | else 33 | narginchk(1,2); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:filter:invalidSizeForIMG')) 41 | end 42 | 43 | % Assign Defaults 44 | alpha = 0.2; 45 | 46 | % Parse Input Arguments 47 | if nargin ~= 1 48 | alpha = varargin{2}; 49 | end 50 | 51 | %% 52 | clearvars -except img alpha 53 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_log.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_log(varargin) 2 | %FILTER_LOG 3 | % [IMG,FILTER_NAME] = FILTER_LOG(IMG,HSIZE,SIGMA) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'hsize' (Optional) 10 | % Default: 5 11 | % 12 | % 'sigma' (Optional) 13 | % Default: 0.5 14 | % 15 | % Notes 16 | % ----- 17 | % 18 | % $SPK 19 | 20 | [img,hsize,sigma] = ParseInputs(varargin{:}); 21 | 22 | h = fspecial('log',hsize,sigma); 23 | J = imfilter(img,h); 24 | 25 | filter_name = ['LoG (',num2str(hsize),'/',num2str(sigma),')']; 26 | 27 | %% 28 | clearvars -except J filter_name 29 | 30 | %-------------------------------------------------------------------------- 31 | function [img,hsize,sigma] = ParseInputs(varargin) 32 | 33 | if verLessThan('matlab', '7.13') 34 | iptchecknargin(1,3,nargin,mfilename); 35 | else 36 | narginchk(1,3); 37 | end 38 | 39 | % Check img 40 | img = varargin{1}; 41 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 42 | if ndims(img) > 3 43 | error(message('images:filter:invalidSizeForIMG')) 44 | end 45 | 46 | % Assign Defaults 47 | hsize = 5; 48 | sigma = 0.5; 49 | 50 | % Parse Input Arguments 51 | if nargin ~= 1 52 | hsize = varargin{2}; 53 | sigma = varargin{3}; 54 | end 55 | 56 | %% 57 | clearvars -except img hsize sigma 58 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_max.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_max(varargin) 2 | %FILTER_MAX Implements a max filter 3 | % [IMG,FILTER_NAME] = FILTER_MAX(IMG,SIZ) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'siz' (Optional) 10 | % Default: 5 11 | % 12 | % Notes 13 | % ----- 14 | % From Gonzalez and Woods 15 | % 16 | % $SPK 17 | 18 | [img,siz] = ParseInputs(varargin{:}); 19 | 20 | J = imdilate(img,ones(siz,siz)); 21 | 22 | filter_name = ['Max (',num2str(siz),')']; 23 | 24 | %% 25 | clearvars -except J filter_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img,siz] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,2,nargin,mfilename); 32 | else 33 | narginchk(1,2); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:filter:invalidSizeForIMG')) 41 | end 42 | 43 | % Assign Defaults 44 | siz = 5; 45 | 46 | % Parse Input Arguments 47 | if nargin ~= 1 48 | siz = varargin{2}; 49 | end 50 | 51 | %% 52 | clearvars -except img siz 53 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_median.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_median(varargin) 2 | %FILTER_MEDIAN 3 | % [IMG,FILTER_NAME] = FILTER_MEDIAN(IMG,HSIZE) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'hsize' (Optional) 10 | % Default: 3 11 | % 12 | % Notes 13 | % ----- 14 | % 15 | % $SPK 16 | 17 | [img,hsize] = ParseInputs(varargin{:}); 18 | 19 | parfor i = 1:size(img,3) 20 | J(:,:,i) = medfilt2(img(:,:,i),[hsize,hsize]); 21 | end 22 | 23 | filter_name = ['Median (',num2str(hsize),')']; 24 | 25 | %% 26 | clearvars -except J filter_name 27 | 28 | %-------------------------------------------------------------------------- 29 | function [img,hsize] = ParseInputs(varargin) 30 | 31 | if verLessThan('matlab', '7.13') 32 | iptchecknargin(1,2,nargin,mfilename); 33 | else 34 | narginchk(1,2); 35 | end 36 | 37 | % Check img 38 | img = varargin{1}; 39 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 40 | if ndims(img) > 3 41 | error(message('images:filter:invalidSizeForIMG')) 42 | end 43 | 44 | % Assign Defaults 45 | hsize = 3; 46 | 47 | % Parse Input Arguments 48 | if nargin ~= 1 49 | hsize = varargin{2}; 50 | end 51 | 52 | %% 53 | clearvars -except img hsize 54 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_midpoint.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_midpoint(varargin) 2 | %FILTER_MIDPOINT Implements a midpoint filter 3 | % [IMG,FILTER_NAME] = FILTER_MIDPOINT(IMG,siz) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'siz' (Optional) 10 | % Default: 5 11 | % 12 | % Notes 13 | % ----- 14 | % From Gonzalez and Woods 15 | % 16 | % $SPK 17 | 18 | [img,siz] = ParseInputs(varargin{:}); 19 | 20 | f1 = ordfilt2(img,1,ones(siz,siz),'symmetric'); 21 | f2 = ordfilt2(img,siz*siz,ones(siz,siz),'symmetric'); 22 | J = imlincomb(0.5,f1,0.5,f2); 23 | 24 | filter_name = ['Midpoint (',num2str(siz),')']; 25 | 26 | %% 27 | clearvars -except J filter_name 28 | 29 | %-------------------------------------------------------------------------- 30 | function [img,siz] = ParseInputs(varargin) 31 | 32 | if verLessThan('matlab', '7.13') 33 | iptchecknargin(1,2,nargin,mfilename); 34 | else 35 | narginchk(1,2); 36 | end 37 | 38 | % Check img 39 | img = varargin{1}; 40 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 41 | if ndims(img) > 3 42 | error(message('images:filter:invalidSizeForIMG')) 43 | end 44 | 45 | % Assign Defaults 46 | siz = 5; 47 | 48 | % Parse Input Arguments 49 | if nargin ~= 1 50 | siz = varargin{2}; 51 | end 52 | 53 | %% 54 | clearvars -except img siz 55 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_min.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_min(varargin) 2 | %FILTER_MIN Implements a min filter 3 | % [IMG,FILTER_NAME] = FILTER_MIN(IMG,SIZ) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'siz' (Optional) 10 | % Default: 5 11 | % 12 | % Notes 13 | % ----- 14 | % From Gonzalez and Woods 15 | % 16 | % $SPK 17 | 18 | [img,siz] = ParseInputs(varargin{:}); 19 | 20 | J = imerode(img,ones(siz,siz)); 21 | 22 | filter_name = ['Min (',num2str(siz),')']; 23 | 24 | %% 25 | clearvars -except J filter_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img,siz] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,2,nargin,mfilename); 32 | else 33 | narginchk(1,2); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:filter:invalidSizeForIMG')) 41 | end 42 | 43 | % Assign Defaults 44 | siz = 5; 45 | 46 | % Parse Input Arguments 47 | if nargin ~= 1 48 | siz = varargin{2}; 49 | end 50 | 51 | %% 52 | clearvars -except img siz 53 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/not currently used/filter_wiener.m: -------------------------------------------------------------------------------- 1 | function [J,filter_name] = filter_wiener(varargin) 2 | %FILTER_WIENER 3 | % [IMG,FILTER_NAME] = FILTER_WIENER(IMG,HSIZE) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'hsize' (Optional) 10 | % Default: 3 11 | % 12 | % Notes 13 | % ----- 14 | % 15 | % $SPK 16 | 17 | [img,hsize] = ParseInputs(varargin{:}); 18 | 19 | parfor i = 1:size(img,3) 20 | J(:,:,i) = wiener2(img(:,:,i),[hsize,hsize]); 21 | end 22 | 23 | filter_name = ['Wiener (',num2str(hsize),')']; 24 | 25 | %% 26 | clearvars -except J filter_name 27 | 28 | %-------------------------------------------------------------------------- 29 | function [img,hsize] = ParseInputs(varargin) 30 | 31 | if verLessThan('matlab', '7.13') 32 | iptchecknargin(1,2,nargin,mfilename); 33 | else 34 | narginchk(1,2); 35 | end 36 | 37 | % Check img 38 | img = varargin{1}; 39 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 40 | if ndims(img) > 3 41 | error(message('images:filter:invalidSizeForIMG')) 42 | end 43 | 44 | % Assign Defaults 45 | hsize = 3; 46 | 47 | % Parse Input Arguments 48 | if nargin ~= 1 49 | hsize = varargin{2}; 50 | end 51 | 52 | %% 53 | clearvars -except img hsize 54 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_filter_ave_hsize3.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_filter_ave_hsize3(img) 2 | %PREPROCESS_FILTER_AVE_HSIZE3 3 | % [IMG,preprocess_NAME] = PREPROCESS_FILTER_AVE_HSIZE3(IMG) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % Notes 10 | % ----- 11 | % 12 | % $SPK 13 | 14 | [img] = ParseInputs(img); 15 | 16 | hsize = 3; 17 | 18 | h = fspecial('average',hsize); 19 | J = imfilter(img,h); 20 | 21 | preprocess_name = ['Average (',num2str(hsize),')']; 22 | 23 | %% 24 | clearvars -except J preprocess_name 25 | 26 | %-------------------------------------------------------------------------- 27 | function [img] = ParseInputs(varargin) 28 | 29 | if verLessThan('matlab', '7.13') 30 | iptchecknargin(1,1,nargin,mfilename); 31 | else 32 | narginchk(1,1); 33 | end 34 | 35 | % Check img 36 | img = varargin{1}; 37 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 38 | if ndims(img) > 3 39 | error(message('images:preprocess:invalidSizeForIMG')) 40 | end 41 | 42 | %% 43 | clearvars -except img 44 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_filter_gradient2D.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_filter_gradient2D(varargin) 2 | %PREPROCESS_FILTER_GRADIENT2D 3 | % [IMG,PREPROCESS_NAME] = PREPROCESS_FILTER_GRADIENT2D(IMG,METHOD) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'method' (Optional) 10 | % Default: 'Sobel' 11 | % 12 | % Notes 13 | % ----- 14 | % 15 | % $SPK 16 | 17 | [img,method] = ParseInputs(varargin{:}); 18 | 19 | switch method 20 | case 'sobel' 21 | h = -fspecial('sobel'); % Align mask correctly along the x- and y- axes 22 | Gx = imfilter(img,h','replicate'); 23 | Gy = imfilter(img,h,'replicate'); 24 | 25 | case 'prewitt' 26 | h = -fspecial('prewitt'); % Align mask correctly along the x- and y- axes 27 | Gx = imfilter(img,h','replicate'); 28 | Gy = imfilter(img,h,'replicate'); 29 | 30 | case 'centraldifference' 31 | [Gx,Gy] = gradient(img); 32 | 33 | case 'intermediatedifference' 34 | Gx = zeros(size(img)); 35 | if (size(img,2) > 1) 36 | Gx(:,1:end-1) = img(:,2:end) - img(:,1:end-1); 37 | end 38 | 39 | Gy = zeros(size(img)); 40 | if (size(img,1) > 1) 41 | Gy(1:end-1,:) = img(2:end,:) - img(1:end-1,:); 42 | end 43 | 44 | case 'roberts' 45 | Gx = imfilter(img,[1 0; 0 -1],'replicate'); 46 | Gy = imfilter(img,[0 1; -1 0],'replicate'); 47 | 48 | otherwise 49 | error('not a valid gradient method') 50 | end 51 | 52 | J = sqrt(Gx.^2+Gy.^2); 53 | 54 | preprocess_name = ['Gradient2D (',method,')']; 55 | 56 | %% 57 | clearvars -except J preprocess_name 58 | 59 | %-------------------------------------------------------------------------- 60 | function [img,method] = ParseInputs(varargin) 61 | 62 | if verLessThan('matlab', '7.13') 63 | iptchecknargin(1,2,nargin,mfilename); 64 | else 65 | narginchk(1,2); 66 | end 67 | 68 | % Check img 69 | img = varargin{1}; 70 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 71 | if ndims(img) > 3 72 | error(message('images:preprocess:invalidSizeForIMG')) 73 | end 74 | 75 | % Assign Defaults 76 | method = 'sobel'; 77 | 78 | % Parse Input Arguments 79 | if nargin ~= 1 80 | method = lower(varargin{2}); 81 | end 82 | 83 | %% 84 | clearvars -except img method 85 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_filter_localentropy.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_filter_localentropy(varargin) 2 | %PREPROCESS_FILTER_LOCALENTROPY 3 | % [IMG,PREPROCESS_NAME] = PREPROCESS_FILTER_LOCALENTROPY(IMG,NHOOD) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'nhood' (Optional) A scalar value the indicates the size of the 10 | % neighborhood 11 | % Default: 3 12 | % 13 | % Notes 14 | % ----- 15 | % 16 | % $SPK 17 | 18 | [img,nhood] = ParseInputs(varargin{:}); 19 | 20 | ind_nan = isnan(img); 21 | 22 | % Change the image bit depth to 8 to be consistent with MATLAB built-in 23 | % function 24 | nl = 256; 25 | gl = [0, 4095]; 26 | slope = nl/(gl(2)-gl(1)); 27 | intercept = 1-(slope*(gl(1))); 28 | img = floor(imlincomb(slope,img,intercept,'double')); 29 | img(img > nl) = nl; 30 | img(img < 1) = 1; 31 | img = img - 1; 32 | img = uint8(img); 33 | 34 | J = entropyfilt(img,true(nhood)); 35 | J(isinf(J)) = nan; 36 | J(ind_nan) = nan; 37 | 38 | preprocess_name = ['Local Entropy Filter (',num2str(nhood),')']; 39 | 40 | %% 41 | clearvars -except J preprocess_name 42 | 43 | %-------------------------------------------------------------------------- 44 | function [img,nhood] = ParseInputs(varargin) 45 | 46 | if verLessThan('matlab', '7.13') 47 | iptchecknargin(1,2,nargin,mfilename); 48 | else 49 | narginchk(1,2); 50 | end 51 | 52 | % Check scanArray 53 | img = varargin{1}; 54 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'I',1); 55 | if ndims(img) > 3 56 | error(message('images:preprocess:invalidSizeForI')) 57 | end 58 | 59 | % Assign Defaults 60 | nhood = 3; 61 | 62 | % Parse Input Arguments 63 | if nargin ~= 1 64 | nhood = varargin{2}; 65 | validateattributes(nhood,{'numeric'},{'scalar','real'},mfilename, 'nhood', 2); 66 | end 67 | 68 | clearvars -except img nhood 69 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_filter_localrange.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_filter_localrange(varargin) 2 | %PREPROCESS_FILTER_LOCALRANGE 3 | % [IMG,PREPROCESS_NAME] = PREPROCESS_FILTER_LOCALRANGE(IMG,NHOOD) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'nhood' (Optional) A scalar value the indicates the size of the 10 | % neighborhood 11 | % Default: 3 12 | % 13 | % Notes 14 | % ----- 15 | % 16 | % $SPK 17 | 18 | [img,nhood] = ParseInputs(varargin{:}); 19 | 20 | img_inf = img; 21 | img_inf(isnan(img)) = inf; 22 | 23 | J = rangefilt(img_inf,true(nhood)); 24 | J(isinf(J)) = nan; 25 | 26 | preprocess_name = ['Local Range Filter (',num2str(nhood),')']; 27 | 28 | %% 29 | clearvars -except J preprocess_name 30 | 31 | %-------------------------------------------------------------------------- 32 | function [img,nhood] = ParseInputs(varargin) 33 | 34 | if verLessThan('matlab', '7.13') 35 | iptchecknargin(1,2,nargin,mfilename); 36 | else 37 | narginchk(1,2); 38 | end 39 | 40 | % Check scanArray 41 | img = varargin{1}; 42 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'I',1); 43 | if ndims(img) > 3 44 | error(message('images:preprocess:invalidSizeForI')) 45 | end 46 | 47 | % Assign Defaults 48 | nhood = 3; 49 | 50 | % Parse Input Arguments 51 | if nargin ~= 1 52 | nhood = varargin{2}; 53 | validateattributes(nhood,{'numeric'},{'scalar','real'},mfilename, 'nhood', 2); 54 | end 55 | 56 | clearvars -except img nhood 57 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_filter_localstd.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_filter_localstd(varargin) 2 | %PREPROCESS_FILTER_LOCALSTD 3 | % [IMG,PREPROCESS_NAME] = PREPROCESS_FILTER_LOCALSTD(IMG,NHOOD) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'nhood' (Optional) A scalar value the indicates the size of the 10 | % neighborhood 11 | % Default: 3 12 | % 13 | % Notes 14 | % ----- 15 | % 16 | % $SPK 17 | 18 | [img,nhood] = ParseInputs(varargin{:}); 19 | 20 | ind_nan = isnan(img); 21 | 22 | J = stdfilt(img,true(nhood)); 23 | J(isinf(J)) = nan; 24 | J(ind_nan) = nan; 25 | 26 | preprocess_name = ['Local STD Filter (',num2str(nhood),')']; 27 | 28 | %% 29 | clearvars -except J preprocess_name 30 | 31 | %-------------------------------------------------------------------------- 32 | function [img,nhood] = ParseInputs(varargin) 33 | 34 | if verLessThan('matlab', '7.13') 35 | iptchecknargin(1,2,nargin,mfilename); 36 | else 37 | narginchk(1,2); 38 | end 39 | 40 | % Check scanArray 41 | img = varargin{1}; 42 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'I',1); 43 | if ndims(img) > 3 44 | error(message('images:preprocess:invalidSizeForI')) 45 | end 46 | 47 | % Assign Defaults 48 | nhood = 3; 49 | 50 | % Parse Input Arguments 51 | if nargin ~= 1 52 | nhood = varargin{2}; 53 | validateattributes(nhood,{'numeric'},{'scalar','real'},mfilename, 'nhood', 2); 54 | end 55 | 56 | clearvars -except img nhood 57 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_filter_log_hsize10_sigma2.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_filter_log_hsize10_sigma2(img) 2 | %PREPROCESS_FILTER_LOG_HSIZE10_SIGMA2 3 | % [IMG,preprocess_NAME] = PREPROCESS_FILTER_LOG_HSIZE10_SIGMA2(IMG) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % Notes 10 | % ----- 11 | % 12 | % $SPK 13 | 14 | [img] = ParseInputs(img); 15 | 16 | hsize = 10; 17 | sigma = 2; 18 | 19 | h = fspecial('log',hsize,sigma); 20 | J = imfilter(img,h); 21 | 22 | preprocess_name = ['LoG Filter (',num2str(hsize),'/',num2str(sigma),')']; 23 | 24 | %% 25 | clearvars -except J preprocess_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,1,nargin,mfilename); 32 | else 33 | narginchk(1,1); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:preprocess:invalidSizeForIMG')) 41 | end 42 | 43 | %% 44 | clearvars -except img 45 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_filter_log_hsize12_sigma2_5.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_filter_log_hsize12_sigma2_5(img) 2 | %PREPROCESS_FILTER_LOG_HSIZE12_SIGMA2_5 3 | % [IMG,preprocess_NAME] = PREPROCESS_FILTER_LOG_HSIZE12_SIGMA2_5(IMG) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % Notes 10 | % ----- 11 | % 12 | % $SPK 13 | 14 | [img] = ParseInputs(img); 15 | 16 | hsize = 12; 17 | sigma = 2.5; 18 | 19 | h = fspecial('log',hsize,sigma); 20 | J = imfilter(img,h); 21 | 22 | preprocess_name = ['LoG Filter (',num2str(hsize),'/',num2str(sigma),')']; 23 | 24 | %% 25 | clearvars -except J preprocess_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,1,nargin,mfilename); 32 | else 33 | narginchk(1,1); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:preprocess:invalidSizeForIMG')) 41 | end 42 | 43 | %% 44 | clearvars -except img 45 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_filter_log_hsize4_sigma1.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_filter_log_hsize4_sigma1(img) 2 | %PREPROCESS_FILTER_LOG_HSIZE4_SIGMA1 3 | % [IMG,preprocess_NAME] = PREPROCESS_FILTER_LOG_HSIZE4_SIGMA1(IMG) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % Notes 10 | % ----- 11 | % 12 | % $SPK 13 | 14 | [img] = ParseInputs(img); 15 | 16 | hsize = 4; 17 | sigma = 1; 18 | 19 | h = fspecial('log',hsize,sigma); 20 | J = imfilter(img,h); 21 | 22 | preprocess_name = ['LoG Filter (',num2str(hsize),'/',num2str(sigma),')']; 23 | 24 | %% 25 | clearvars -except J preprocess_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,1,nargin,mfilename); 32 | else 33 | narginchk(1,1); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:preprocess:invalidSizeForIMG')) 41 | end 42 | 43 | %% 44 | clearvars -except img 45 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_filter_log_hsize6_sigma1_5.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_filter_log_hsize6_sigma1_5(img) 2 | %PREPROCESS_FILTER_LOG_HSIZE6_SIGMA1_5 3 | % [IMG,preprocess_NAME] = PREPROCESS_FILTER_LOG_HSIZE6_SIGMA1_5(IMG) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % Notes 10 | % ----- 11 | % 12 | % $SPK 13 | 14 | [img] = ParseInputs(img); 15 | 16 | hsize = 6; 17 | sigma = 1.5; 18 | 19 | h = fspecial('log',hsize,sigma); 20 | J = imfilter(img,h); 21 | 22 | preprocess_name = ['LoG Filter (',num2str(hsize),'/',num2str(sigma),')']; 23 | 24 | %% 25 | clearvars -except J preprocess_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,1,nargin,mfilename); 32 | else 33 | narginchk(1,1); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:preprocess:invalidSizeForIMG')) 41 | end 42 | 43 | %% 44 | clearvars -except img 45 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_filter_log_hsize8_sigma1_8.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_filter_log_hsize8_sigma1_8(img) 2 | %PREPROCESS_FILTER_LOG_HSIZE8_SIGMA1 3 | % [IMG,preprocess_NAME] = PREPROCESS_FILTER_LOG_HSIZE8_SIGMA1.8(IMG) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % Notes 10 | % ----- 11 | % 12 | % $SPK 13 | 14 | [img] = ParseInputs(img); 15 | 16 | hsize = 8; 17 | sigma = 1.8; 18 | 19 | h = fspecial('log',hsize,sigma); 20 | J = imfilter(img,h); 21 | 22 | preprocess_name = ['LoG Filter (',num2str(hsize),'/',num2str(sigma),')']; 23 | 24 | %% 25 | clearvars -except J preprocess_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,1,nargin,mfilename); 32 | else 33 | narginchk(1,1); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:preprocess:invalidSizeForIMG')) 41 | end 42 | 43 | %% 44 | clearvars -except img 45 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_threshold.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_threshold(varargin) 2 | %PREPROCESS_THRESHOLD 3 | % [IMG,PREPROCESS_NAME] = PREPROCESS_THRESHOLD(IMG,THRESHOLD) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % 'threshold' (Optional) 10 | % Default: 1000 11 | % 12 | % Notes 13 | % ----- 14 | % 15 | % $SPK 16 | 17 | [img,threshold] = ParseInputs(varargin{:}); 18 | 19 | J = img; 20 | J(J>threshold) = nan; 21 | 22 | preprocess_name = ['Threshold (',num2str(threshold),')']; 23 | 24 | %% 25 | clearvars -except J preprocess_name 26 | 27 | %-------------------------------------------------------------------------- 28 | function [img,threshold] = ParseInputs(varargin) 29 | 30 | if verLessThan('matlab', '7.13') 31 | iptchecknargin(1,2,nargin,mfilename); 32 | else 33 | narginchk(1,2); 34 | end 35 | 36 | % Check img 37 | img = varargin{1}; 38 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 39 | if ndims(img) > 3 40 | error(message('images:preprocess:invalidSizeForIMG')) 41 | end 42 | 43 | % Assign Defaults 44 | threshold = 1000; 45 | 46 | % Parse Input Arguments 47 | if nargin ~= 1 48 | threshold = varargin{2}; 49 | end 50 | 51 | %% 52 | clearvars -except img threshold 53 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_threshold250.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_threshold250(img) 2 | %PREPROCESS_THRESHOLD250 3 | % [IMG,PREPROCESS_NAME] = PREPROCESS_THRESHOLD250(IMG) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % Notes 10 | % ----- 11 | % 12 | % $SPK 13 | 14 | [img] = ParseInputs(img); 15 | 16 | threshold = 250; 17 | 18 | J = img; 19 | J(J>threshold) = nan; 20 | 21 | preprocess_name = ['Threshold (',num2str(threshold),')']; 22 | 23 | %% 24 | clearvars -except J preprocess_name 25 | 26 | %-------------------------------------------------------------------------- 27 | function [img] = ParseInputs(varargin) 28 | 29 | if verLessThan('matlab', '7.13') 30 | iptchecknargin(1,1,nargin,mfilename); 31 | else 32 | narginchk(1,1); 33 | end 34 | 35 | % Check img 36 | img = varargin{1}; 37 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 38 | if ndims(img) > 3 39 | error(message('images:preprocess:invalidSizeForIMG')) 40 | end 41 | 42 | %% 43 | clearvars -except img 44 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_threshold500.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_threshold500(img) 2 | %PREPROCESS_THRESHOLD500 3 | % [IMG,PREPROCESS_NAME] = PREPROCESS_THRESHOLD500(IMG) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % Notes 10 | % ----- 11 | % 12 | % $SPK 13 | 14 | [img] = ParseInputs(img); 15 | 16 | threshold = 500; 17 | 18 | J = img; 19 | J(J>threshold) = nan; 20 | 21 | preprocess_name = ['Threshold (',num2str(threshold),')']; 22 | 23 | %% 24 | clearvars -except J preprocess_name 25 | 26 | %-------------------------------------------------------------------------- 27 | function [img] = ParseInputs(varargin) 28 | 29 | if verLessThan('matlab', '7.13') 30 | iptchecknargin(1,1,nargin,mfilename); 31 | else 32 | narginchk(1,1); 33 | end 34 | 35 | % Check img 36 | img = varargin{1}; 37 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 38 | if ndims(img) > 3 39 | error(message('images:preprocess:invalidSizeForIMG')) 40 | end 41 | 42 | %% 43 | clearvars -except img 44 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/preprocess_threshold750.m: -------------------------------------------------------------------------------- 1 | function [J,preprocess_name] = preprocess_threshold750(img) 2 | %PREPROCESS_THRESHOLD750 3 | % [IMG,PREPROCESS_NAME] = PREPROCESS_THRESHOLD750(IMG) 4 | % 5 | % Parameters include: 6 | % 7 | % 'img' Self explanatory 8 | % 9 | % Notes 10 | % ----- 11 | % 12 | % $SPK 13 | 14 | [img] = ParseInputs(img); 15 | 16 | threshold = 750; 17 | 18 | J = img; 19 | J(J>threshold) = nan; 20 | 21 | preprocess_name = ['Threshold (',num2str(threshold),')']; 22 | 23 | %% 24 | clearvars -except J preprocess_name 25 | 26 | %-------------------------------------------------------------------------- 27 | function [img] = ParseInputs(varargin) 28 | 29 | if verLessThan('matlab', '7.13') 30 | iptchecknargin(1,1,nargin,mfilename); 31 | else 32 | narginchk(1,1); 33 | end 34 | 35 | % Check img 36 | img = varargin{1}; 37 | validateattributes(img,{'numeric'},{'real','nonsparse'},mfilename,'img',1); 38 | if ndims(img) > 3 39 | error(message('images:preprocess:invalidSizeForIMG')) 40 | end 41 | 42 | %% 43 | clearvars -except img 44 | -------------------------------------------------------------------------------- /texture/tex_prep/tex_preprocess/read_preprocess.m: -------------------------------------------------------------------------------- 1 | function [preprocess_names,func_names,preprocess] = read_preprocess 2 | %% Get the name of the preprocessing routines 3 | mainDir = fileparts(which('read_preprocess')); 4 | 5 | preprocess_names = cell(0); 6 | func_names = cell(0); 7 | 8 | list = dir(mainDir); 9 | for i = 1:numel(list) 10 | if ~isempty(regexpi(list(i).name,'^preprocess(\w*).m$')) 11 | func_names{end+1,1} = strrep(list(i).name,'.m',''); 12 | [~,preprocess_names{end+1,1}] = feval(func_names{end,1},1); 13 | end 14 | end 15 | 16 | preprocess = strrep(strrep(strrep(strrep(strrep(preprocess_names,' ','_'),'(',''),')',''),'/','_'),'.','p'); 17 | 18 | %% 19 | clearvars -except preprocess_names func_names preprocess 20 | -------------------------------------------------------------------------------- /texture/textureX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/texture/textureX.fig -------------------------------------------------------------------------------- /utilities/data_exportX.m: -------------------------------------------------------------------------------- 1 | function data_exportX(project_path, output_path) 2 | 3 | [~,project_name] = fileparts(project_path); 4 | output_dir = [datestr(now,'yyyymmdd'),' ',project_name]; 5 | copyfile(fullfile(project_path,'*.mat'),fullfile(output_path,output_dir)) 6 | -------------------------------------------------------------------------------- /utilities/dicom_fields.trex: -------------------------------------------------------------------------------- 1 | Filename 2 | FileModDate 3 | FileSize 4 | Format 5 | FormatVersion 6 | Width 7 | Height 8 | BitDepth 9 | ColorType 10 | FileMetaInformationGroupLength 11 | MediaStorageSOPClassUID 12 | MediaStorageSOPInstanceUID 13 | TransferSyntaxUID 14 | ImplementationClassUID 15 | ImplementationVersionName 16 | SourceApplicationEntityTitle 17 | IdentifyingGroupLength 18 | SpecificCharacterSet 19 | ImageType 20 | InstanceCreationDate 21 | InstanceCreationTime 22 | SOPClassUID 23 | SOPInstanceUID 24 | StudyDate 25 | SeriesDate 26 | AcquisitionDate 27 | ContentDate 28 | StudyTime 29 | SeriesTime 30 | AcquisitionTime 31 | ContentTime 32 | AccessionNumber 33 | Modality 34 | Manufacturer 35 | InstitutionName 36 | StationName 37 | StudyDescription 38 | SeriesDescription 39 | ManufacturerModelName 40 | PatientGroupLength 41 | PatientID 42 | PatientBirthDate 43 | PatientSex 44 | PatientAge 45 | AdditionalPatientHistory 46 | AcquisitionGroupLength 47 | ScanOptions 48 | SliceThickness 49 | KVP 50 | DataCollectionDiameter 51 | SoftwareVersion 52 | ProtocolName 53 | ReconstructionDiameter 54 | DistanceSourceToDetector 55 | DistanceSourceToPatient 56 | GantryDetectorTilt 57 | TableHeight 58 | RotationDirection 59 | ExposureTime 60 | XrayTubeCurrent 61 | Exposure 62 | FilterType 63 | GeneratorPower 64 | FocalSpot 65 | ConvolutionKernel 66 | PatientPosition 67 | RevolutionTime 68 | SingleCollimationWidth 69 | TotalCollimationWidth 70 | TableSpeed 71 | TableFeedPerRotation 72 | SpiralPitchFactor 73 | RelationshipGroupLength 74 | StudyInstanceUID 75 | SeriesInstanceUID 76 | StudyID 77 | SeriesNumber 78 | AcquisitionNumber 79 | InstanceNumber 80 | ImagePositionPatient 81 | ImageOrientationPatient 82 | FrameOfReferenceUID 83 | PositionReferenceIndicator 84 | SliceLocation 85 | ImagePresentationGroupLength 86 | SamplesPerPixel 87 | PhotometricInterpretation 88 | Rows 89 | Columns 90 | PixelSpacing 91 | BitsAllocated 92 | BitsStored 93 | HighBit 94 | PixelRepresentation 95 | PixelPaddingValue 96 | WindowCenter 97 | WindowWidth 98 | RescaleIntercept 99 | RescaleSlope 100 | RescaleType 101 | PerformedProcedureStepStartDate 102 | PerformedProcedureStepStartTime 103 | PerformedProcedureStepID 104 | PerformedProcedureStepDescription 105 | PixelDataGroupLength 106 | -------------------------------------------------------------------------------- /utilities/oldROI_deleteX.m: -------------------------------------------------------------------------------- 1 | function oldROI_deleteX(project_path) 2 | %% 3 | extractRead = read_extractX(project_path); 4 | 5 | project_patient = unique(extractRead.project_patient); 6 | 7 | for j = 1:numel(project_patient) 8 | list = dir(project_patient{j}); 9 | 10 | for i = 1:numel(list) 11 | if ~isempty(regexpi(list(i).name, '^2015')) || ~isempty(regexpi(list(i).name, '^2014')) || ~isempty(regexpi(list(i).name, '^2013')) 12 | disp(list(i).name) 13 | delete(fullfile(project_patient{j},list(i).name)) 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /utilities/pinnacle_imageX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/utilities/pinnacle_imageX.fig -------------------------------------------------------------------------------- /utilities/projectmodules_copyX.m: -------------------------------------------------------------------------------- 1 | function projectmodules_copyX(project_path,dest_path) 2 | %% 3 | if isempty(project_path) 4 | project_path = uigetdir; 5 | end 6 | 7 | [~,project_name] = fileparts(project_path); 8 | 9 | try 10 | mkdir(fullfile(dest_path,project_name)) 11 | copyfile(fullfile(project_path,'*.mat'),... 12 | fullfile(dest_path,project_name)) 13 | 14 | mkdir(fullfile(dest_path,project_name,'Log')) 15 | copyfile(fullfile(project_path,'Log'),... 16 | fullfile(dest_path,project_name,'Log')) 17 | catch 18 | 19 | end 20 | -------------------------------------------------------------------------------- /utilities/rawdvh_exportX.m: -------------------------------------------------------------------------------- 1 | function [out] = rawdvh_exportX(project_path, module, output_path) 2 | 3 | try 4 | files = dir(fullfile(project_path,'Log')); 5 | 6 | %Find the most current _TEXTUREX file 7 | date = 0; 8 | for i = 1:numel(files) 9 | if ~isempty(regexpi(files(i).name,['_',module,'_doseX.mat$'])) 10 | filedate = str2double(files(i).name(1:14)); 11 | 12 | if filedate > date 13 | date = filedate; 14 | end 15 | end 16 | end 17 | 18 | %Create the filename 19 | filename = [num2str(date),'_',module,'_doseX.mat']; 20 | 21 | %Load the data 22 | dvh = load(fullfile(project_path,'Log',filename)); 23 | 24 | 25 | %% 26 | bin_length = nan(numel(dvh.patient_mrn),1); 27 | for i = 1:numel(dvh.patient_mrn) 28 | bin_length(i) = length(dvh.bins_dvh{i}); 29 | end 30 | 31 | out = dvh; 32 | 33 | out.diff_dvh = nan(numel(dvh.patient_mrn),max(bin_length)); 34 | out.cumul_dvh = nan(numel(dvh.patient_mrn),max(bin_length)); 35 | 36 | [~,ind] = max(bin_length); 37 | out.bins_dvh = dvh.bins_dvh{ind}; 38 | 39 | for i = 1:numel(dvh.patient_mrn) 40 | out.diff_dvh(i,1:length(dvh.diff_dvh{i,1})) = dvh.diff_dvh{i,1}; 41 | out.cumul_dvh(i,1:length(dvh.cumul_dvh{i,1})) = dvh.cumul_dvh{i,1}; 42 | end 43 | 44 | if ~isempty(output_path) 45 | save(fullfile(output_path,['RAW',upper(module),'.mat']),'-struct','out') 46 | end 47 | 48 | catch err 49 | out = []; 50 | end -------------------------------------------------------------------------------- /utilities/readImg_dicomX.m: -------------------------------------------------------------------------------- 1 | function [img] = readImg_dicomX(data_dir,SeriesInstanceUID) 2 | 3 | select = strcmpi({data_dir.dicom_SeriesInstanceUID}, SeriesInstanceUID); 4 | 5 | if sum(select) == 0 6 | img = nan; 7 | else 8 | filename = {data_dir(select).dicom_Filename}; 9 | number = [data_dir(select).dicom_InstanceNumber]; 10 | slope = [data_dir(select).dicom_RescaleSlope]; 11 | intercept = [data_dir(select).dicom_RescaleIntercept]; 12 | 13 | [~,ind] = sort(number); 14 | filename = filename(ind); 15 | 16 | %% 17 | img = []; 18 | for i = 1:numel(filename) 19 | img(:,:,i) = dicomread(filename{i}); 20 | img(:,:,i) = img(:,:,i)*slope(i) + intercept(i); 21 | end 22 | 23 | img = img + 1000; 24 | img(img<0) = 0; 25 | end 26 | 27 | clearvars -except img -------------------------------------------------------------------------------- /utilities/reduce_trexdata.m: -------------------------------------------------------------------------------- 1 | function reduce_trexdata(data_path) 2 | %% 3 | modules = {'HIST','GLCM','GLRLM','NGTDM','LAWS2D','LUNG','SHAPE'}; 4 | %% 5 | for i = 1:length(modules) 6 | %% 7 | read_dat = load(fullfile(data_path,modules{i})); 8 | 9 | out = cell(0); 10 | out.patient_mrn = read_dat.patient_mrn; 11 | out.plan_name = read_dat.plan_name; 12 | out.image_seriesUID = read_dat.image_seriesUID; 13 | out.parameter_headings = read_dat.parameter_headings; 14 | out.parameter_names = read_dat.parameter_names; 15 | out.feature_names = read_dat.feature_names; 16 | out.feature_space = read_dat.feature_space; 17 | 18 | save(fullfile(data_path,[modules{i},'_reduce.mat']),'-struct','out') 19 | end 20 | 21 | -------------------------------------------------------------------------------- /utilities/scanDir_dicomX.m: -------------------------------------------------------------------------------- 1 | %-------------------------------------------------------------------------- 2 | function [data_dir] = scanDir_dicomX(project_dir) 3 | %% 4 | w = waitbar(0,'Please wait...'); 5 | 6 | mainDir = fileparts(which('TREX')); 7 | fields = readcsvX(fullfile(mainDir,'utilities','dicom_fields.trex')); 8 | 9 | files = subdirX(project_dir); 10 | numel(files) 11 | 12 | [g] = emptyg(fields); 13 | data_dir = cell(numel(files),numel(fieldnames(g))); 14 | 15 | for j = 1:numel(files) 16 | waitbar(j/numel(files),w); 17 | 18 | [g] = emptyg(fields); 19 | 20 | if ~isempty(regexpi(files(j).name,'\w*.(img|dcm)')) || ~isempty(regexpi(files(j).name,'^(CT|PT)')) 21 | 22 | info = dicominfo(files(j).name); 23 | % info = dicominfo(fullfile(project_dir,files(j).name)); 24 | % fields = fieldnames(info); 25 | 26 | for k = 1:numel(fields) 27 | % switch fields{k} 28 | try 29 | g.(['dicom_', fields{k}]) = info.(fields{k}); 30 | catch err 31 | end 32 | 33 | end 34 | end 35 | 36 | data_dir(j,:) = struct2cell(g); 37 | end 38 | 39 | data_dir = [fieldnames(g)'; data_dir]; 40 | 41 | data_dir(all(cellfun(@isempty,data_dir),2),:) = []; 42 | % data_dir = cell2dataset(data_dir); 43 | % data_dir = cell2struct(data_dir(2:end,:),data_dir(1,:),2); 44 | 45 | close(w) 46 | 47 | % save('image_data.mat','data_dir') 48 | %% 49 | clearvars -except data_dir 50 | 51 | %% 52 | function [g] = emptyg(fields) 53 | 54 | g = cell(0); 55 | 56 | for i = 1:numel(fields) 57 | g.(['dicom_', fields{i}]) = ''; 58 | end 59 | % 60 | -------------------------------------------------------------------------------- /utilities/verify_pinnaclectX.m: -------------------------------------------------------------------------------- 1 | function [out] = verify_pinnaclectX(dicom_data,trexproj_dir) 2 | 3 | extractRead = read_extractX(trexproj_dir); 4 | 5 | % Find the unique scans in the project... 6 | [~,ind] = unique(extractRead.image_seriesUID); 7 | f_names = fieldnames(extractRead); 8 | for i = 1:numel(f_names) 9 | extractRead.(f_names{i}) = extractRead.(f_names{i})(ind); 10 | end 11 | 12 | % out = []; 13 | % out.mrn = nan(numel(extractRead.patient_mrn),1); 14 | % out.uid = cell(numel(extractRead.patient_mrn),1); 15 | % out.median = cell(numel(extractRead.patient_mrn),1); 16 | % out.mean = cell(numel(extractRead.patient_mrn),1); 17 | % out.max = cell(numel(extractRead.patient_mrn),1); 18 | 19 | w = waitbar(0,'Verifying Pinnacle CT Number...'); 20 | 21 | parfor i = 1:numel(extractRead.patient_mrn) 22 | % waitbar(i/numel(extractRead.patient_mrn),w); 23 | disp(i) 24 | pinn = load(fullfile(extractRead.project_patient{i},extractRead.image_file{i})); 25 | img1 = double(pinn.array); 26 | 27 | img2 = readImg_dicomX(dicom_data,pinn.image_seriesUID); 28 | 29 | out(i).mrn = extractRead.patient_mrn(i); 30 | out(i).uid = pinn.image_seriesUID; 31 | 32 | if isnan(img2) 33 | out(i).median = 'no matching dicom'; 34 | out(i).mean = 'no matching dicom'; 35 | out(i).max = 'no matching dicom'; 36 | elseif ~all(size(img1) == size(img2)) 37 | out(i).median = 'dimensions differ'; 38 | out(i).mean = 'dimensions differ'; 39 | out(i).max = 'dimensions differ'; 40 | else 41 | d = img2 - img1; 42 | 43 | out(i).median = median(d(:)); 44 | out(i).mean = mean(d(:)); 45 | out(i).max = max(d(:)); 46 | end 47 | end 48 | 49 | close(w) 50 | 51 | clearvars -except out 52 | -------------------------------------------------------------------------------- /viewer/scaleCurvedata_viewerX.m: -------------------------------------------------------------------------------- 1 | function [h] = scaleCurvedata_viewerX(h) 2 | %% 3 | start_rngx = [h.img.array_xV(1),h.img.array_xV(end)]; 4 | rngx = [1,h.entry.image_xdim]; 5 | 6 | start_rngy = [h.img.array_yV(1),h.img.array_yV(end)]; 7 | rngy = [1,h.entry.image_ydim]; 8 | 9 | start_rngz = [h.img.array_zV(1),h.img.array_zV(end)]; 10 | rngz = [1,h.entry.image_zdim]; 11 | 12 | h.roi.x = []; 13 | h.roi.y = []; 14 | h.roi.z = []; 15 | 16 | for cCount = 1:numel(h.roi.curvedata) 17 | tempx = rngx(1)+((rngx(2)-rngx(1))*(h.roi.curvedata{cCount}(:,1)-start_rngx(1)))./... 18 | (start_rngx(2)-start_rngx(1)); 19 | 20 | tempy = rngy(1)+((rngy(2)-rngy(1))*(h.roi.curvedata{cCount}(:,2)-start_rngy(1)))./... 21 | (start_rngy(2)-start_rngy(1)); 22 | 23 | tempz = rngz(1)+((rngz(2)-rngz(1))*(h.roi.curvedata{cCount}(:,3)-start_rngz(1)))./... 24 | (start_rngz(2)-start_rngz(1)); 25 | 26 | h.roi.x = [h.roi.x; tempx]; 27 | h.roi.y = [h.roi.y; tempy]; 28 | h.roi.z = [h.roi.z; tempz]; 29 | end 30 | 31 | %% 32 | clearvars -excpet h 33 | -------------------------------------------------------------------------------- /viewer/viewerX.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spkrafft/trex/c3ed39bed7fd61ef91c6dd777ffa4f66dd1615b4/viewer/viewerX.fig --------------------------------------------------------------------------------