Skip to content

Commit

Permalink
Merge pull request #11 from uw-loci/Usability-Feedback-Round-2
Browse files Browse the repository at this point in the history
Usability feedback round 2 Complete
  • Loading branch information
Surnus15 authored Dec 1, 2018
2 parents a98851d + cce07ee commit 5d0d736
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 125 deletions.
2 changes: 1 addition & 1 deletion Processing Code/File Naming Convention Guide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ As a direct output from the steering code you will have one top directory with m


The top directory should end in:
_[number of images in the x-dimension]x_[number of images in the y-dimension]y_[number of images in the z-dimension]z_[depth of cutting between z-slices]um_cuts
_[number of images in the x-dimension]x_[number of images in the y-dimension]y_[number of images in the z-dimension]z_[depth of cutting between z-slices][cut scale (um,mm,cm)]_cuts
e.g. 2018-10-16-Tiled_Beads_20x_1ms_3x_3y_3z_10um_cuts where 2018-10-16-Tiled_Beads_20x_1ms is the data set name


Expand Down
94 changes: 16 additions & 78 deletions Processing Code/Functions/Axial_Sectioning_Framework_v11.m
Original file line number Diff line number Diff line change
@@ -1,91 +1,29 @@
function [] = Axial_Sectioning_Framework_v11(...
steering_code_raw_data_flag, microscope_configuration, ...
img_save_type, rec_mode, file_path, max_int, sim_points, ...
img_save_type, rec_mode, file_path, bit_depth, sim_points, ...
save_intermediaries_flag, flat_field_flag, flat_field_path, ...
overlap_percent, threshold_percent)
%% Axial Sectioning Structured Illumination Reconstruction Framework
% By: Niklas Gahm
% 2017/06/29
%
% This is a framework that loads up the needed images to be processed and
% reconstructed for an axial sectioning system
%
% Variables:
% max_int - The maximum intensity to be used in an output image.
% out_of_focus_flag - This is a binary flag for whether or not the
% image sequence being reconstructed is from an out of
% focus plane, if so an in-focus image needs to be
% acquired for normalization purposes.
% batch_flag - This is a binary flag to tell the script that
% all images in the folder should be processed using
% the specified method
% rejection_profile_flag - This is a binary flag to tell the script
% to generate a rejection profile from a series of images
% it needs to have batch_flag = 1 and
% out_of_focus_flag = 1 to work.
% rejection_step_size - This is the step size between the image
% sequences used to generate the rejection profile.
% rejection_step_size_units - This is the units in which the step
% size are. This is used to display on the rejection
% profile graph, so please format it appropriately.
% rejection_profile_name - This is the name that will be used to save
% all the rejection profiles that are used.
% steering_code_raw_data_flag - This is a flag that all the data is
% straight from the co-designed steering code.
% microscope_configuration - This is the configuration file to use
% which contains multiple variables based on the
% configuration of the hardware used.
%
% Usage:
% When you run the framework please select the first image of the
% series that is being used for reconstruction, make sure that the
% files end in {i, j, or k} for a 3 image reconstruction. If the
% sequence is from an out-of-focus plane you will need to have an
% in-focus image to normalize the intensity to.
% When using the in-focus batch mode, out_of_focus_flag = 0,
% batch_flag = 1) this script will ignore all sub-folders within the
% folder selected.
% When using the out-of-focus batch mode, (out_of_focus_flag = 1,
% batch_flag = 1) you will select a folder wherein all sub folders
% will be ignored and it is assumed you are following a naming
% convention of IF_[name]_[i,j,...] and OF_[name]_[1,2,...]_[i,j,...]
% wherein [1,2,...] are the in-sequence stepping out from the
% in-focus point.
% When using the rejection profile generator please follow the
% out-of-focus batch mode usage guidelines. Make sure that your image
% sequences are at an even step size spacing and that you fill in the
% appropriate rejection_step_size and rejection_step_size_units. Also
% each unique set of lp/mm need to be in their own folder. And there
% need to be no other folders present. This assumes each sub-folder
% is labelled as [lp/mm]_lpmm
% The umanager_raw_flag mode exists solely to make the data
% organizing easier. It should only be used the first time since it
% solely exists to re-organize and re-name the data properly. It can
% only be used in batch mode.
% This is a framework called by a corresponding GUI which loads a series
% of images, processes, reconstructs, tiles, and saves them for an axial
% sectioning system.
%
% Supported Filetypes:
% .tif
%
% Supported Microscope Configurations:
% SETI_4x_460nm - SETI Microscope with 4x Nikon Plan APO using 460nm
% wavelength
% SETI_10x_460nm -
%
% Supported Reconstruction Types
% 3_Sub_Image - Basic SIM reconstruction with 3 images {i,j,k}
% 4_Sub_Image - Basic SIM reconstruction with 3 images {i,j,k,u}
% 5_Sub_Image - Basic SIM reconstruction with 3 images {i,j,k,u,w}
%
% Supported Reconstruction Modes
% Single Image - This is for reconstructing a single in-focus image
% Image Batch - This is for reconstructing a set of arbritrary
% in-focus images
% Z-Stack - This is for reconstructing a z-stack from a batch of raw
% images
% Atlas - This is for reconstructing an xy larger stitched together
% image
% Atlas Z-Stack - This is for reconstructing an xy stitched together
% atlas image which also has multiple z-depths
% Image Stack - This is for reconstructing an image cube from a batch
% of raw images
% Rejection Profile - This is for generating an out-of-field
% rejection profile from a batch of images which
% will have theory matched to each rejection profile
Expand All @@ -94,11 +32,6 @@
% Common Actuators Used for Stepping:
% SETI - Newport Precision 100 TPI - 254 um per 1 turn
%
% To Be Added:
% - Flat-Field Correction
% - Add z-stack 3D Rendering Prep
% - Add Atlasing
%
% 2017/06/29 - Started
% 2017/06/29 - Finished Initial Version
% 2017/07/05 - Finished Adding In-Focus Batch Mode
Expand All @@ -110,6 +43,7 @@
% 2017/08/07 - Fixed Ascending Order Bug
% 2017/12/04 - Fixed Rejection Profile Theory
% 2017/12/06 - Improved User Interface
% 2018/11/30 - Finished Full Release Version



Expand Down Expand Up @@ -140,6 +74,10 @@
num_z] = arch_path_generator(file_path);


%% Calculated Variables
max_int = (2^bit_depth) - 1;


%% Generate Useful Struct of Naming Conventions
rec_type_variables = {{'i'}, {'i', 'j'}, {'i', 'j', 'k'}, ...
{'i', 'j', 'k', 'u'}, {'i', 'j', 'k', 'u', 'w'}};
Expand All @@ -161,19 +99,19 @@
%% Pre-Processing
fprintf('\nPre-Processing Data\n');
[ img_sets ] = axial_framework_pre_processing_v2( img_sets, max_int, ...
rec_mode, file_path, img_save_type, save_intermediaries_flag, ...
flat_field_flag, flat_field_path );
bit_depth, rec_mode, file_path, img_save_type, ...
save_intermediaries_flag, flat_field_flag, flat_field_path );


%% Reconstruction
fprintf('\nReconstructing Images\n');
[ img_sets ] = sim_img_reconstructer_v3( img_sets, file_path, ...
img_save_type );
img_save_type, bit_depth );


% No Tiling or Rejection Profiles if the Image Sets are Just Random
% Locations in the Sample
if ~strcmp(rec_mode, 'Misc. Image Batch')
if ~strcmp(rec_mode, 'Individual Images')
%% Generate Real lp/mm
fprintf('\nCalculating Line Pair/mm\n');
[ img_sets ] = pixel_widths_2_lpmm_v2( img_sets, f_number, obj_mag, ...
Expand All @@ -193,7 +131,7 @@

%% Save Tiled Images as Stacks
fprintf('\nSaving Tiled Image Stacks\n');
axial_img_z_stack_saver(img_sets, file_path, img_save_type);
axial_img_z_stack_saver(img_sets, file_path, img_save_type, bit_depth);


% If the Image Sets are Not Rejection Profile Based, Finish After
Expand Down
Binary file modified Processing Code/Functions/Axial_Sectioning_Framework_v11_GUI.fig
Binary file not shown.
86 changes: 52 additions & 34 deletions Processing Code/Functions/Axial_Sectioning_Framework_v11_GUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

% Edit the above text to modify the response to help Axial_Sectioning_Framework_v11_GUI

% Last Modified by GUIDE v2.5 29-Nov-2018 09:50:32
% Last Modified by GUIDE v2.5 30-Nov-2018 17:33:42

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
Expand Down Expand Up @@ -115,9 +115,23 @@ function process_data_button_Callback(hObject, eventdata, handles)
error('No Folder Selected for Processing.')
end

% Get BitDepth
switch get(handles.bit_depth, 'Value')
case 1
bit_depth = 8;
case 2
bit_depth = 16;
case 3
bit_depth = 32;
case 4
bit_depth = 64;
otherwise
error('Invalid Output Bit Depth Selected');
end


% Get Values
steering_code_raw_data_flag = get(handles.steering_code_raw, 'Value');
max_int = str2double(get(handles.max_int, 'String'));
sim_points = str2double(get(handles.sim_points, 'String'));
overlap_percent = str2double(get(handles.overlap_percent, 'String')) / 100;
threshold_percent = str2double(get(handles.threshold_percent, ...
Expand Down Expand Up @@ -146,7 +160,7 @@ function process_data_button_Callback(hObject, eventdata, handles)
% Run Axial Sectioning Framework
Axial_Sectioning_Framework_v11(steering_code_raw_data_flag, ...
microscope_configuration_file, img_save_type, rec_mode, fpath, ...
max_int, sim_points, save_intermediaries_flag, flat_field_flag, ...
bit_depth, sim_points, save_intermediaries_flag, flat_field_flag, ...
flat_field_path, overlap_percent, threshold_percent);

% Close GUI
Expand All @@ -162,6 +176,7 @@ function steering_code_raw_Callback(hObject, eventdata, handles)
% Hint: get(hObject,'Value') returns toggle state of steering_code_raw



% --- Executes on selection change in microscope_config_file.
function microscope_config_file_Callback(hObject, eventdata, handles)
% hObject handle to microscope_config_file (see GCBO)
Expand Down Expand Up @@ -218,6 +233,7 @@ function microscope_config_file_CreateFcn(hObject, eventdata, handles)
end



% --- Executes on selection change in rec_mode_select.
function rec_mode_select_Callback(hObject, eventdata, handles)
% hObject handle to rec_mode_select (see GCBO)
Expand All @@ -226,15 +242,12 @@ function rec_mode_select_Callback(hObject, eventdata, handles)

% Make Sure a Valid Selection Is Made
rec_mode_num = get(handles.rec_mode_select, 'Value');
if rec_mode_num > 4
if rec_mode_num > 3
uiwait(msgbox('Please Select a Supported Form of Reconstruction'));
end

% Set Panel Visibility
rec_mode_list = get(handles.rec_mode_select, 'String');
if rec_mode_num > 3
error('Unsupported Reconstrution Mode');
end
rec_mode = rec_mode_list{rec_mode_num};
handles = panel_visibility_setter(rec_mode, handles);

Expand All @@ -255,6 +268,7 @@ function rec_mode_select_CreateFcn(hObject, eventdata, handles)
end



% --- Executes on button press in process_folder_selection.
function process_folder_selection_Callback(hObject, eventdata, handles)
% hObject handle to process_folder_selection (see GCBO)
Expand All @@ -274,28 +288,6 @@ function process_folder_selection_Callback(hObject, eventdata, handles)



function max_int_Callback(hObject, eventdata, handles)
% hObject handle to max_int (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of max_int as text
% str2double(get(hObject,'String')) returns contents of max_int as a double


% --- Executes during object creation, after setting all properties.
function max_int_CreateFcn(hObject, eventdata, handles)
% hObject handle to max_int (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in save_intermediaries_flag.
function save_intermediaries_flag_Callback(hObject, eventdata, handles)
% hObject handle to save_intermediaries_flag (see GCBO)
Expand Down Expand Up @@ -328,6 +320,7 @@ function sim_points_CreateFcn(hObject, eventdata, handles)
end



% --- Executes on button press in flat_field_flag.
function flat_field_flag_Callback(hObject, eventdata, handles)
% hObject handle to flat_field_flag (see GCBO)
Expand Down Expand Up @@ -399,6 +392,31 @@ function threshold_percent_CreateFcn(hObject, eventdata, handles)



% --- Executes on selection change in bit_depth.
function bit_depth_Callback(hObject, eventdata, handles)
% hObject handle to bit_depth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns bit_depth contents as cell array
% contents{get(hObject,'Value')} returns selected item from bit_depth


% --- Executes during object creation, after setting all properties.
function bit_depth_CreateFcn(hObject, eventdata, handles)
% hObject handle to bit_depth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end





% Function to check and set Panel visibility
function handles = panel_visibility_setter(rec_mode, handles)
Expand All @@ -417,8 +435,8 @@ function threshold_percent_CreateFcn(hObject, eventdata, handles)

end

% Function to set all the ToolTip Strings

% Function to set all the ToolTip Strings
function handles = tooltip_string_setter(handles)
% Reconstruction Mode Tooltip
rec_mode_str_1 = 'Select how the processing code will reconstruct your images.';
Expand Down Expand Up @@ -459,10 +477,10 @@ function threshold_percent_CreateFcn(hObject, eventdata, handles)
set(handles.text8, 'TooltipString', ...
selected_folder_flat_field_str_full);

% Maximum Integer Tooltip
max_int_str_full = 'Set the maximum integer value output images should contain.';
set(handles.text6, 'TooltipString', max_int_str_full);
set(handles.max_int, 'TooltipString', max_int_str_full);
% Bit Depth Tooltip
bit_depth_str_full = 'Select the Bit Depth output images should contain.';
set(handles.text6, 'TooltipString', bit_depth_str_full);
set(handles.bit_depth, 'TooltipString', bit_depth_str_full);

% Image Save Type Tif Tooltip
img_save_type_tif_str_full = 'Select for all output images to be saved as .tif';
Expand Down
12 changes: 9 additions & 3 deletions Processing Code/Functions/axial_framework_pre_processing_v2.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function [ img_sets ] = axial_framework_pre_processing_v2( img_sets, ...
max_int, rec_mode, fpath, img_save_type, save_intermediaries_flag, ...
flat_field_flag, flat_field_path)
max_int, bit_depth, rec_mode, fpath, img_save_type, ...
save_intermediaries_flag, flat_field_flag, flat_field_path)
%% Axial Framework Pre-Processing
% By: Niklas Gahm
% 2018/07/23
Expand Down Expand Up @@ -63,11 +63,17 @@
for i = 1:numel(img_sets)
spath = [fpath '\' img_sets(i).name '\Pre-processed Images'];
mkdir(spath);
wait_element = waitbar((1/numel(img_sets(i).images)), ...
sprintf('Saving Pre-Processed Sub-Images From %s', ...
img_sets(i).name));
for j = 1:numel(img_sets(i).images)
bfsave(uint8(img_sets(i).images(j).image_processed), ...
waitbar((j/numel(img_sets(i).images)), wait_element);
bfsave( img_bit_depth_converter( ...
img_sets(i).images(j).image_processed, bit_depth ), ...
[spath '\' img_sets(i).images(j).name '_pre-processed' ...
img_save_type]);
end
close(wait_element);
end
end

Expand Down
Loading

0 comments on commit 5d0d736

Please sign in to comment.