Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "stackin"]
path = stackin
url = https://github.com/RJ3/stackin.git
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Damon McCullough

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ Rhythm is a MATLAB-based graphical user interface to display, condition, and ana
* Ability to create movies and export individual signals

# Requirements
We recommend the latest release of 64-bit MATLAB on a 64-bit machine. We have tested this package on both windows and mac platforms. This code was originally created for a mac. While functionality is unchanged on windows machines, GUI display may be a bit irregular on MATLAB for windows.
We recommend the latest release of 64-bit MATLAB on a 64-bit machine. We have tested this package on both windows and mac platforms. This code was originally created for a mac. While functionality is unchanged on windows machines, GUI display may be a bit irregular on MATLAB for windows.

*MATLAB 9.5
*Signal Processing Toolbox 8.1
*Image Processing Toolbox 10.3
*Statistics and Machine Learning Toolbox 11.4

# Contributions
If you would like to contribute to this project, please contact Dr. Igor Efimov at igor@wustl.edu. If you find this code helpful, please reference our review paper describing proper analysis of optical mapping data found at http://www.ncbi.nlm.nih.gov/pubmed/22821993

# Nottice!!!
# Notice!!!
Until we can fully perfect the use of Github distribution, we recommend the URL (Google Drive) below for the most up-to-date release of Rhythm
https://drive.google.com/folderview?id=0BxA1B_i6ZEvlflptaFlBUlJVNTUtTVUyQzJldnNGc3hneldhVHhVNmhhTjV2M3VmNHY5TlE&usp=sharing
26 changes: 18 additions & 8 deletions aMap.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [actMap1] = aMap(data,stat,endp,Fs,bg,cmap,filename)
function [actMap1] = aMap(data,startt,endt,Fs,bg,cmap,filename,dir)
%% aMap is the central function for creating conduction velocity maps
% [actMap1] = aMap(data,stat,endp,Fs,bg) calculates the activation map
% for a single action potential upstroke.
Expand All @@ -19,6 +19,8 @@
% cmap = a colormap input that facilites the potential inversion of the
% colormap. cmap is stored in the handles structure as handles.cmap.
%
% dir = directory to output csv to
%
%
% OUTPUT
% actMap1 = activation map
Expand Down Expand Up @@ -48,8 +50,8 @@

%% Code
% Create initial variables
stat=round(stat*Fs);
endp=round(endp*Fs);
stat=round(startt*Fs);
endp=round(endt*Fs);
actMap = zeros(size(data,1),size(data,2));
mask2 = zeros(size(data,1),size(data,2));
temp = data(:,:,stat:endp); % windowed signal
Expand Down Expand Up @@ -79,9 +81,10 @@
actMap1 = actMap1/Fs*1000; %% time in ms

% Plot Map
zz = figure('Name','Activation Map');
actMapPeriod = " " + num2str(round(startt, 3)) + " - " + num2str(round(endt, 3));
zz = figure('Name',strcat('Activation Map: ',actMapPeriod));
contourf(flipud(actMap1),endp-stat,'LineColor','none')
title('Activation Map')
title(strcat('Activation Map: ',actMapPeriod))
axis image
axis off
colormap(cmap);
Expand All @@ -90,15 +93,22 @@
% User prompt for input to create csv
prompt1 = {'Save activation map for CV analysis?'};
dlg_title1 = 'Save activation map';
num_lines1 = 1;
direc='/home/lab/Documents/Langendorff-MEHP/ActMaps/';
def1 = {strcat(direc,'ActMap-',filename,'.csv')};
num_lines1 = [1 60];
direc=dir;
file = strtok(filename,'.'); % Get filename without extension
def1 = {strcat(direc,'/ActMaps/ActMap-',file,'.csv')};
answer = inputdlg(prompt1,dlg_title1,num_lines1,def1);
% process user inputs
if isempty(answer) % cancel save if user clicks "cancel"
return
end
filename = answer{1};

% create the ActMaps folder if it doesn't exist already.
newSubFolder = strcat(direc,'/ActMaps/');
if ~exist(newSubFolder, 'dir')
mkdir(newSubFolder);
end
csvwrite(filename,actMap1);


Expand Down
25 changes: 24 additions & 1 deletion apdMap.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [apdMap] = apdMap(data,start,endp,Fs,percent,cmap)
function [apdMap] = apdMap(data,start,endp,Fs,percent,cmap,filename,dir)
%% the function apdMap creates a visual representation of the action potential duration
%
% INPUTS
Expand Down Expand Up @@ -100,4 +100,27 @@
figure('Name','Histogram of APD')
hist(reshape(apdMap,[],1),floor(APD_max-APD_min))
%xlim([APD_min APD_max])



% User prompt for input to create csv
prompt1 = {'Save APD map?'};
dlg_title1 = 'Save APD map';
num_lines1 = [1 60];
file = strtok(filename,'.'); % Get filename without extension
def1 = {strcat(dir,'/APDMaps/APD-',file,'.csv')};
answer = inputdlg(prompt1,dlg_title1,num_lines1,def1);
% process user inputs
if isempty(answer) % cancel save if user clicks "cancel"
return
end
filename = answer{1};

% create the APDMaps folder if it doesn't exist already.
newSubFolder = strcat(dir,'/APDMaps/');
if ~exist(newSubFolder, 'dir')
mkdir(newSubFolder);
end
csvwrite(filename,apdMap);

end
Binary file removed atsifiomex.mexa64
Binary file not shown.
4 changes: 3 additions & 1 deletion binning.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
data(data==0) = NaN;

avePattern = ones(N,N);
for i = 1:size(data,3)
parfor i = 1:size(data,3) % for each frame of the data
% get the N*N cmos data for the frame
temp = data(:,:,i);
% replace temp with
temp = 1/N/N*conv2(temp,avePattern,'same');
data(:,:,i) = temp;
end
2 changes: 1 addition & 1 deletion filter_data.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
%% Apply Filter
temp = reshape(data,[],size(data,3));
filt_temp = zeros(size(temp));
for i = 1:size(temp,1)
parfor i = 1:size(temp,1)
if sum(temp(i,:)) ~= 0
filt_temp(i,:) = filtfilt(b,a,temp(i,:)); % needed to create 0 phase offset
end
Expand Down
25 changes: 22 additions & 3 deletions normalize_data.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,28 @@
% divides by the difference between the min and max.

%% Code
min_data = repmat(min(data,[],3),[1 1 size(data,3)]);
diff_data = repmat(max(data,[],3)-min(data,[],3),[1 1 size(data,3)]);
normData = (data-min_data)./(diff_data);
disp('(normalize_data.m) Starting ')

disp('(normalize_data.m) Calculation min_data... ')
min_data = repmat(min(data,[],3), [1 1 size(data,3)]);

disp('(normalize_data.m) Calculation diff_data... ')
diff_data = repmat(max(data,[],3) - min(data,[],3), [1 1 size(data,3)]);
% normData = (data-min_data)./(diff_data);
% data_temp = data - min_data;

% Subtraction
disp('(normalize_data.m) Subtraction... ')
% data_temp = bsxfun(@minus, data, min_data);
data = bsxfun(@minus, data, min_data);
clear min_data

% Division
disp('(normalize_data.m) Division... ')
normData = rdivide(data, diff_data);
clear diff_data

disp('(normalize_data.m) Done ')
% % %% NON RECTANGULAR POLYGON MOD
% % min_data = repmat(min(data,[],2),[1 size(data,2)]);
% % diff_data = repmat(max(data,[],2),[1 size(data,2)])-min_data;
Expand Down
2 changes: 1 addition & 1 deletion remove_BKGRD.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
BG = mat2gray(bg);
level = graythresh(BG);
BW = im2bw(BG,level*thresh);
BW2 = bwareaopen(BW, perc_ex*size(BG,1)*size(BG,2));
BW2 = bwareaopen(BW, floor(perc_ex*size(BG,1)*size(BG,2)));
BW3 = imfill(BW2,'holes');
mask = repmat(BW3,[1 1 size(data,3)]);
new_data = data.*mask;
Expand Down
2 changes: 1 addition & 1 deletion remove_Drift.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
tempy = reshape(data,size(data,1)*size(data,2),[]);
temp_ord = ord_str{1};
ord = str2num(temp_ord(1));
for i = 1:size(data,1)*size(data,2)
parfor i = 1:size(data,1)*size(data,2)
if sum(tempy(i,:)) ~= 0
[p,s,mu] = polyfit(tempx,tempy(i,:),ord);
y_poly = polyval(p,tempx,s,mu);
Expand Down
Loading