Skip to content

Commit

Permalink
Updates to color and ss fade thres
Browse files Browse the repository at this point in the history
Updated PlotProbe2 and GUI to have short separation fade option. Also has different color plotting features for different conditions.
  • Loading branch information
duwadisudan committed Mar 1, 2024
1 parent 5673605 commit ed5284f
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 5 deletions.
Binary file modified PlotProbe2GUI/PlotProbe2.fig
Binary file not shown.
81 changes: 76 additions & 5 deletions PlotProbe2GUI/PlotProbe2.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 PlotProbe2

% Last Modified by GUIDE v2.5 22-Mar-2022 16:55:43
% Last Modified by GUIDE v2.5 22-Feb-2024 10:25:49

% Return if snirf object was not passed
if isempty(varargin)
Expand Down Expand Up @@ -172,6 +172,8 @@ function PlotProbe2_OpeningFcn(hObject, eventdata, handles, varargin)
end
set(handles.edit_minDistForDisplay, 'String', min_dist);
set(handles.edit_maxDistForDisplay, 'String', max_dist);
defualtssFadeThres = 0;
set(handles.edit_ssFadeThres, 'String', num2str(defualtssFadeThres));

condition_names = {' All'};
for u = 1:length(snirfObj.stim)
Expand Down Expand Up @@ -332,6 +334,8 @@ function display(handles)

channel_min_dist = str2double(get(handles.edit_minDistForDisplay, 'String'));
channel_max_dist = str2double(get(handles.edit_maxDistForDisplay, 'String'));
ssFadeThres = str2double(get(handles.edit_ssFadeThres, 'String'));

% contents = cellstr(get(handles.listbox_selectConditions,'String'));
selected_conditions_index = get(handles.listbox_selectConditions,'Value');
data_index = 0;
Expand All @@ -357,10 +361,54 @@ function display(handles)
for u = 1:length(snirfObj.data(data_index).measurementList)
activityConditionIndex = GetCondition(snirfObj.data(data_index).measurementList(u));
if any(selected_conditions_index == 1) || any(selected_conditions_index == activityConditionIndex+1)

% for HbO
color_condition_1 = [0.862, 0.078, 0.235]; % Red for condition 1
color_condition_2 = [1, 0, 1]; % Magenta for condition 2

% for HbR
color_condition_3 = [0, 0, 0.8]; % Blue for condition 1
color_condition_4 = [0, 1, 1]; % Cyan for condition 2

% for HbT
color_condition_5 = [0.133, 0.545, 0.133]; % Dark green for condition 1
color_condition_6 = [0.5, 1, 0]; % Light pastel green for condition 2

% before selecting conditions, initialize the colors as:

current_color_HbO = color_condition_1;
current_color_HbR = color_condition_3;

if any(selected_conditions_index == 2) && activityConditionIndex + 1 == 2
current_color_HbO = color_condition_1; % Red for condition 1
current_color_HbR = color_condition_3; % Blue for condition 2
current_color_HbT = color_condition_5; % for condition 3
elseif any(selected_conditions_index == 3) && activityConditionIndex + 1 == 3
current_color_HbO = color_condition_2; % Magenta for condition 2
current_color_HbR = color_condition_4; % Cyan for condition 2
current_color_HbT = color_condition_6; % for condition 2
end


srcIdx = GetSourceIndex(snirfObj.data(data_index).measurementList(u));
detIdx = GetDetectorIndex(snirfObj.data(data_index).measurementList(u));
detIdx = GetDetectorIndex(snirfObj.data(data_index).measurementList(u));


channel_dist = sqrt(sum((sourcePos3D(srcIdx,:) - detectorPos3D(detIdx ,:)).^2));

fade_factor = 0.7;

if channel_dist >= 0 && channel_dist <= ssFadeThres
% Use a faded color or different line style for short separation
% Light gray color for faded effect
current_color_HbO = current_color_HbO + (1-current_color_HbO)*fade_factor;
current_color_HbR = current_color_HbR + (1-current_color_HbR)*fade_factor;
current_color_HbT = current_color_HbT + (1-current_color_HbT)*fade_factor;

else

end

if channel_dist >= channel_min_dist & channel_dist <= channel_max_dist
xa = (sPos(srcIdx,1) + dPos(detIdx ,1))/2 - axXoff;
ya = (sPos(srcIdx,2) + dPos(detIdx ,2))/2 - axYoff;
Expand Down Expand Up @@ -408,11 +456,11 @@ function display(handles)


if any(contains(selected_display_activities,dataTypeLabel)) & contains(dataTypeLabel,'HbO')
plot( xT, AvgT,'color',color(1,:));
plot(xT, AvgT, 'color', current_color_HbO);
elseif any(contains(selected_display_activities,dataTypeLabel)) & contains(dataTypeLabel,'HbR')
plot( xT, AvgT,'color',color(2,:));
plot( xT, AvgT,'color', current_color_HbR);
elseif any(contains(selected_display_activities,dataTypeLabel)) & contains(dataTypeLabel,'HbT')
plot( xT, AvgT,'color',color(3,:));
plot( xT, AvgT,'color',current_color_HbT);
elseif any(contains(selected_display_activities,dataTypeLabel))
plot( xT, AvgT,'color',color(4,:));
end
Expand Down Expand Up @@ -824,3 +872,26 @@ function listbox_selectActivity_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end



function edit_ssFadeThres_Callback(hObject, eventdata, handles)
% hObject handle to edit_ssFadeThres (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 edit_ssFadeThres as text
% str2double(get(hObject,'String')) returns contents of edit_ssFadeThres as a double


% --- Executes during object creation, after setting all properties.
function edit_ssFadeThres_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_ssFadeThres (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

0 comments on commit ed5284f

Please sign in to comment.