ATLAS Personal Trainer Download
Download the zip folder for the ATLAS Personal Trainer here !
Thanks,
Mhomo Kadiri.
h
$LAYYYTER
tumblr dot com
we're not kids anymore.
KIROKAZE

Kaledo Art

roma★
One Nice Bug Per Day
Peter Solarz
YOU ARE THE REASON
I'd rather be in outer space 🛸
Monterey Bay Aquarium

Love Begins

Origami Around
Alisa U Zemlji Chuda

Product Placement
he wasn't even looking at me and he found me

ellievsbear
d e v o n

seen from Malaysia

seen from Malaysia

seen from South Korea

seen from Austria

seen from United Kingdom

seen from China

seen from Malaysia
seen from Vietnam
seen from United States

seen from Singapore
seen from United States

seen from Germany

seen from United Kingdom

seen from Germany
seen from United States
seen from United States

seen from United States

seen from United Kingdom

seen from Australia

seen from Germany
@typicaltech
ATLAS Personal Trainer Download
Download the zip folder for the ATLAS Personal Trainer here !
Thanks,
Mhomo Kadiri.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Achievement Counter
Define all variables and containers.
div.xx9 { width: 700px; height: 640px; border: none; font-family: helvetica; font-weight: 100; margin: 0 auto;} div.xx9 div { float: left; width: 98%; height: 100%; border: none;} div.xx9 div table#table1 { margin: 5px auto;} div.xx9 div table#table1 tr td { text-align: center; padding: 20px 50px;} div.xx9 div table#table1 tr td div { width: 120px; height: 120px; line-height: 120px; color: white; font-family: consolas; font-size: 19px; border-radius: 100%; border: none; background-color: rgb(90,91,94);} div.xx9 div table#table1 tr td div:hover { background-color: #66cc92; cursor: pointer;}
<?php include "Calc_Macros.php"; ?> <? // DEFINE THE WIDTH OF THE BARS $w1 = floor($carbs_amount * 7)/1000; $w2 = floor($protein_amount * 7)/1000; $w3 = number_format(($fat_amount * 7)/1000, 2); ?> <?php // PROVIDE LOGIN DATA $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "Atlas";
// CREATE AND VERIFY CONNECTION $con = mysqli_connect($servername, $username, $password, $dbname);// Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // CREATE AND RUN SQL QUERY $sql="SELECT * FROM `Biometrics` WHERE Weight=(SELECT MAX(Weight) FROM `Biometrics`);"; // Store the DATA if ($result=mysqli_query($con,$sql)) { // Fetch one and one row while ($row=mysqli_fetch_row($result)) { $GLOBALS["Max_Weight"]=$row[1]; } // Free result set mysqli_free_result($result); } // CREATE AND RUN SQL QUERY $sql2="SELECT * FROM `Biometrics` WHERE LeanMass=(SELECT MAX(leanMass) FROM `Biometrics`);"; // Store the DATA if ($result2=mysqli_query($con,$sql2)) { // Fetch one and one row while ($row=mysqli_fetch_row($result2)) { $GLOBALS["Max_LM"]=$row[2]; } // Free result set mysqli_free_result($result2); } // CREATE AND RUN SQL QUERY $sql3="SELECT * FROM `Biometrics` WHERE BodyFat=(SELECT Min(BodyFat) FROM `Biometrics`);"; // Store the DATA if ($result3=mysqli_query($con,$sql3)) { // Fetch one and one row while ($row=mysqli_fetch_row($result3)) { $GLOBALS["Min_BodyFat"]=$row[3]; } // Free result set mysqli_free_result($result3); } // CLOSE THE CONNECTION mysqli_close($con); ?>
<?php echo $w1." kg"; ?> <?php echo $w2." kg"; ?> <?php echo $w3." kg"; ?> <?php echo floor($Max_Weight)." lbs"; ?> <?php echo $Max_LM." lbs"; ?> <?php echo $Min_BodyFat." %"; ?>
Measurement Display
<?php // Provide the LOGIN instructions $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "Atlas"; // Create connection and verify that it is connected $con = mysqli_connect($servername, $username, $password, $dbname);// Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // Create the SQL query $sql = "SELECT * FROM `Measurements` WHERE Week=(SELECT MAX(Week) FROM `Measurements`);"; // Store the DATA if ($result=mysqli_query($con,$sql)) { // Fetch one and one row while ($row=mysqli_fetch_row($result)) { $GLOBALS["Biceps"] =$row[3]; $GLOBALS["Chest"] =$row[4]; $GLOBALS["Shoulder"] =$row[5]; $GLOBALS["Waist"] =$row[6]; $GLOBALS["Thigh"] =$row[7]; $GLOBALS["Calf"] =$row[8]; $GLOBALS["Hips"] =$row[9]; $GLOBALS["Neck"] =$row[10]; } // Free result set mysqli_free_result($result); }
// QUERY THE PREVIOUS WEEK // Create the SQL query $sql2 = "SELECT * FROM `Measurements` WHERE Week=(SELECT MAX(Week)-1 FROM `Measurements`);"; // Store the DATA if ($result2=mysqli_query($con,$sql2)) { // Fetch one and one row while ($row=mysqli_fetch_row($result2)) { $GLOBALS["Biceps_2"] =$row[3]; $GLOBALS["Chest_2"] =$row[4]; $GLOBALS["Shoulder_2"] =$row[5]; $GLOBALS["Waist_2"] =$row[6]; $GLOBALS["Thigh_2"] =$row[7]; $GLOBALS["Calf_2"] =$row[8]; $GLOBALS["Hips_2"] =$row[9]; $GLOBALS["Neck_2"] =$row[10]; } // Free result set mysqli_free_result($result2); }
// SOLVE THE DIFFERENCE $GLOBALS["Biceps_diff"] = $Biceps - $Biceps_2; $GLOBALS["Chest_diff"] = $Chest - $Chest_2; $GLOBALS["Shoulder_diff"] = $Shoulder - $Shoulder_2; $GLOBALS["Waist_diff"] = $Waist - $Waist_2; $GLOBALS["Thigh_diff"] = $Thigh - $Thigh_2; $GLOBALS["Calf_diff"] = $Calf - $Calf_2; $GLOBALS["Hips_diff"] = $Hips - $Hips_2; $GLOBALS["Neck_diff"] = $Neck - $Neck_2; mysqli_close($con); ?>
<? // Set the header of the page ?> <head> <style> div.xx7 { width: 100%; height: 450px; padding: 60px; border: none; letter-spacing: 1.1px; position: static;} div.xx7 div { float: left;} div.xx7 div table tr { color: #606060 ; font-size: 18px; font-family: helvetica; font-weight: 100;} div.xx7 div table tr td { padding: 5px;;} div.xx7 div table tr td div { width: 50px; height: 50px; border-radius: 100%; border: none; color: white; font-family: consolas; line-height: 50px; font-size: 16px; text-align: center;} div.xx7 div table tr td div.stat { color: #66cc92; border: 1px solid rgb(90,91,94);} </style> </head> <? // The body of the page ?> <body> <div class = "xx7"> <div>  </div> </div> </div> </body>
Meal Graph
Define all variables and create containers
div.xx8 { width: 600px; height: 300px; margin: 0 auto; font-size: 14px; color: rgb(90, 91, 94); border: 1px solid transparent; } div.xx8 div table tr td { margin: 10px 40px; } .bar { transition: fill .3s ease; cursor: pointer; font-family: Helvetica, sans-serif; fill: rgb(90, 91, 94); } .bar text { color: black; font-family: helvetica; font-size: 15px; } .bar:hover, .bar:focus { fill: #66cc92; } .bar:hover text, .bar:focus text { fill: #66cc92; } <?php include "Calc_Macros.php"; ?>
<? // DEFINE THE WIDTH OF THE BARS $max_amount = 500; $box_width = 600; $w1 = floor(($carbs_amount/$max_amount) * $box_width); $w2 = floor(($protein_amount/$max_amount) * $box_width); $w3 = floor(($fat_amount/$max_amount) * $box_width); ?> A bar chart showing Meal Quantities " height="40" y="40"> " y="40" dy="1.75em"> <?php echo "Carbonhydrates : ".$carbs_amount." (g)"; ?> " height="40" y="130"> " y="130" dy="1.75em"> <?php echo "Protein : ".$protein_amount." (g)"; ?> " height="40" y="220"> " y="220" dy="1.75em"> <?php echo "Fats : ".$fat_amount." (g)"; ?> " y="300" style="font-family: consolas;">
<?php echo $max_amount; ?>
Copyright 2017 | Mhomo Kadiri
2017
Happy New Year everyone.
I spent the last 2 months of 2016 working on a new fitness app, codenamed “ATLAS” - a nod to my love for Greek mythology.
Here, I am exploring the relationship between constant biometric tracking and workout efficiency. The results so far have been promising.
Feel free to download the attached source code, and let me know what you think.
Note: If you cannot host the site on your network server, you may like to try MAMP (a free local server for Mac and PC).
Thanks,
Mhomo Kadiri - Lead Designer

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Update
Over the course of the last 2 years, I learnt 5 more programming languages (HTML/CSS, PHP, Java, and SQL).
Using my new found knowledge, I worked on different types of projects; each one varying from the last, both in scale and complexity. I believe that exploring my creativity allowed me a fundamental understanding of how the languages worked. With each iteration, I became reasonably better at the task.
In the next few weeks, I will outline my major projects along with their source-codes. This may be of interest for anyone who wants to further my ideas on their own or work together to make it better.
P.S - If you spot a bug or something I did inefficiently, kindly shoot me a message and I’ll look into it.
Thanks,
Mhomo Kadiri.
Signal Analysis
%% BMES 202: Code 7_1 %% CODE function [data, emg_labels] = ca07_fun1(txt_file) %% 1. If the file name is not provided by the user, prompt the user to select a file, the program should %'remember' the previous user selection if nargin<1 if ~exist('fig1','var') fig1=figure; set(fig1,'filename','DEFAULT.txt'); end [fnm,pth]=uigetfile('*.txt','Choose a File',get(fig1,'filename')); txt_file=fullfile(pth,fnm); end %% 2. Read data into the function (data) data=load(txt_file); set(fig1,'userdata',data); %% 3. Read the header line and get the labels (emg_labels) for the EMG signals tfid=fopen(txt_file); tline=fgetl(tfid); fclose(tfid); emg_labels=regexp(tline,'\t','split'); %% 4. In figure 1, create a subplot for each muscle, and plot emg (y) versus time (x) (as ALWAYS label % your axes & ALL subplots must have the SAME y limits) figure(fig1) subplot(2,2,1) plot(data(:,1),data(:,2)) xlabel('Time (s)') ylabel('Masseter (mV)') title('Masseter Muscle') subplot(2,2,2) plot(data(:,1),data(:,3)) xlabel('Time (s)') ylabel('Biceps (mV)') title('Biceps Muscle') subplot(2,2,3) plot(data(:,1),data(:,4)) xlabel('Time (s)') ylabel('Quadriceps (mV)') title('Quadriceps Muscle') subplot(2,2,4) plot(data(:,1),data(:,5)) xlabel('Time (s)') ylabel('Abdominals (mV)') title('Abdominals Muscle') axH = findall(gcf,'type','axes'); set(axH,'ylim',[-.5 .5]); %% 5. Title the plot with the name of the file (strip the path) suptitle(fnm) end %% BMES 202: Code 7_2 %% CODE function [dtF] = ca07_fun2(data, filt_opts) %% 1. If the user does not provide filter options (filt_opts), you must prompt the user to input the low- %pass filter stop frequency (Hz) [F_stop], and the sub-sampling rate (Hz) %[F_ss]. if ~exist('filt_opts','var') if ~exist('fig2','var') fig2=figure; inp=inputdlg({'Choose the Pass Filter Stop Frequency (Hz)','Choose the sub-sampling rate (Hz)'},'Enter Information',1,{'0.5','2'}); inpn(1)=str2num(inp{1}); inpn(2)=str2num(inp{2}); set(fig2,'userdata',inpn); end filt_opts=get(fig2,'userdata'); end %% 7. Remove any 'bias' from the signal (detrend) dt=detrend(data(:,2:5)); %% 8. Create a 5th order low-pass butterworth filter (butter) using the stop-frequency from filt_opts [b,a]=butter(5,filt_opts(1)/filt_opts(2)); %% 9. Apply filter to detrended data (filter) dtf=filter(b,a,dt); %% 10. Down-sample the filtered data (downsample), based on the sub-sample frequency from filt_opts dtfd=downsample(dtf,filt_opts(2)); dtft=downsample(data(:,1),filt_opts(2)); dtF=[dtft dtfd]; %% 11. In figure 2, create a subplot of time versus each filtered/sub-sampled emg signal (be sure to label %axes with the emg labels figure(fig2) subplot(4,1,1) plot(dtF(:,1),dtF(:,2)) ylabel('Masseter (mV)') subplot(4,1,2) plot(dtF(:,1),dtF(:,3)) ylabel('Biceps (mV)') subplot(4,1,3) plot(dtF(:,1),dtF(:,4)) ylabel('Quadriceps (mV)') subplot(4,1,4) plot(dtF(:,1),dtF(:,5)) xlabel('Time (s)') ylabel('Abdominals (mV)') suptitle('Time vs Each Filtered/Sub-Sampled EMG Signal') end %% BMES 202: Code 7_3 %% CODE function [dtS, dt_sum] = ca07_fun3(dtF, sp_opts) % Based on the input data (dtF [Mx5]) and the spectral % options (sp_opts [1x2]), this function should calculate the spectral power, display the results in figure 3, % and output a summary of the key spectral parameters (dt_sum [4x5]). %% 12. If the user does not provide spectral options (sp_opts), you must prompt the user to input the ... minimum tremore frequency (Hz) [F_min], and the maximum tremor frequency (Hz) [F_max]. !!!!! ... The program MUST remember what the user input last time.!!!!! (Hint, you can store and retrieve ... information from figure 2 object). if ~exist('sp_opts','var') if exist('Hfig2','var') [F_min,F_max]=get(Hfig2,'data'); else answers=inputdlg({'F_min','F_max'},'Please select Spectral Powers',1,{'20','20'}); end end %% 13. Determine the sampling frequency (Fs) using nqist, and using a frequency resolution of 1.0 Hz (frq_res), ... determine the number of frequencies (Nfrq = 2*Fs/frq_res, must be an INTEGER) frq_res=1; Fs = 1/mean(diff(dtF(:, 1))); %Frequency is the inverse of the period Nfrq = 2*Fs/frq_res; %% 14.Loop through all EMG signals, and calculate the spectral power (yP) (periodogram(dtF(:,i), [], ... 'onesided', Nfrq, Fs)) ... 14. Loop through all EMG signals, and calculate the spectral power (yP) ... (periodogram(dtF(:,i), [], 'onesided', Nfrq, Fs)) for i=2:5 % for all of the muscle groups [yP(:,i), Frq(:,i)] = periodogram(dtF(:,i), [], 'onesided', Nfrq, Fs); % run a periodogram and store the spectral powers in yP and frequencies % in frq end %% 15. Determine max spectral power and frequency of max spectral power for ... each signal [dtS, ind] = max(yP); % the max yP for each column is stored in dtS Frq_max = Frq(ind);% the maximum frequency is found at the indices %% 16.Calculate the cumulative spectral power (cumtrapz) (cP) for i=2:5 cP(:,i)=cumtrapz(Frq(:,i),yP(:,i)); end %% 17. ...Loop through emg signals, and calculate the percentage of cumulative spectral power (cPp), and ...determine the cPp at the F_min and F_max (interp1), as well as the frequency at 50% cPp ...(interp1) s=length(cP); for I=2:5 for i=1:s(1) cPp(i,I)=(cP(i,I)./cP(s(1),I))*100; end [F_max(I),F_maxi(I)]=max(Frq(:,I)); [F_min(I),F_mini(I)]=min(Frq(:,I)); cPp_fmax(I)=interp1(Frq(:,I),cPp(:,I),F_max(I)); cPp_fmin(I)=interp1(Frq(:,I),cPp(:,I),F_min(I)); cPp50(I)=interp1(Frq(:,I),cPp(:,I),50); f50(I)=interp1(cPp(:,I),Frq(:,I),50); end %% 18. In figure 3, in subplot1, plot freq (x) versus spectral power (y) for all emg signals (add legend, and ... use '.-' for the line style). Hfig3 = findobj('tag','spectral power'); if(isempty(Hfig3)); Hfig3 = figure('tag','spectral power'); end subplot(2,1,1); plot(Frq,yP,'-'); xlim([0 100]); ylim([0 0.0004149]); title('Frequency vs Spectral Power'); xlabel('Frequency'); ylabel('Spectral Power'); legend('Frequency vs Spectral Power'); grid on; %% 19. In figure 3, subplot2, plot freq (x) versus percentage cumulative spectral power (y), subplot(2,1,2); plot(Frq,cPp,'-'); hold on %and overlay the min/max tremor frequencies plot(F_min,F_max); %needs fixing hold off xlim([0 100]); ylim([0 200]); title('Frequency vs Percentage cumulative spectral power'); xlabel('Frequency'); ylabel('Percentage cumulative spectral power'); legend('Frequency vs Percentage cumulative spectral power', 'Min tremor frequencies','Max tremor frequencies'); grid on; %% 20.Summary output should contain: % 1. Freq at Max SP % 2. Max SP % 3. freq at 50% CSP % 4. 50% CSP % 5. fmin_tremor % 6. %CSP at fmin_tremor % 7. fmax_tremor % 8. %CSP at fmax_tremor % 9. %CSP between fmax_tremor and fmin_tremor new_mat=[Frq_max;dtS;f50;cPp50;F_min;cPp_fmin;F_max;cPp_fmax;[cPp_fmax-cPp_fmin]]; dt_sum=(new_mat(:,2:end))' return; %% BMES 202: Code 7_4 %% CODE %function ca07_fun4; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Master script, which calls functions 1-3 %% and formats the results %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %--- read EMG data clear dt1 emg_lbls [dt1, emg_lbls] = ca07_fun1; %--- filter EMG data clear dtF dtF = ca07_fun2(dt1); %-- spectral analysis clear dtP dt_sum [dtP, dt_sum] = ca07_fun3(dtF); %% Format output %-- get filename from figure 1 handle clear hfig1 txt_file t_pth t_fnm t_ext hfig1 = findobj('tag','EMG-data'); txt_file = get(hfig1,'filename'); %--- strip path [t_pth,t_fnm,t_ext]=fileparts(txt_file); %% Summarize output clear out_txt out_txt(1,1) = {sprintf('%%File:\t%s',[t_fnm,t_ext])}; out_txt(2,1) = {sprintf(['%%Muscle\t', ... 'fmx(Hz)\tPmx()\t', ... 'f50(Hz)\tCSP_50()\t', ... 'f1(Hz)\tcPf1(%%)\t', ... 'f2(Hz)\tcPf2(%%)\t', ... 'cP_rng(%%)'])}; for(i=1:length(emg_lbls)) out_txt(i+2,1) = {sprintf(['%s\t', ... '%.1f\t%.2e\t', ... '%.1f\t%.2e\t', ... '%.1f\t%.1f\t', ... '%.1f\t%.1f\t', ... '%.1f'], ... char(emg_lbls(i)), ... dt_sum(i,:))}; end %--- display to screen disp(char(out_txt)); return;
RESULTS
%% MHOMO KADIRI (c)2014
Image Sample Normalization
%% BMES 202: Code 5_1 %% CODE function im1 = ca05_fun1(img_file) % [import data] % If no input is given, use the 'filename' property from the figure object (hfig1) as the default ...file name in the uigetfile command, (if no figure object exists, create it and set the 'tag', ...'name', and 'filename' properties) Hfig1 = findobj('tag','img_org'); if(isempty(Hfig1)); Hfig1 = figure('tag','img_org','Name', 'Original Image'); end if nargin==0; filename = get(Hfig1,'FileName'); [fnm,pth] = uigetfile('*.*','Choose Image File',filename); img_file = fullfile(pth,fnm); end %% % set the 'filename' property of the figure object (hfig1) to be the name (full name) of the % user selected file set(Hfig1,'filename',img_file); % read the data from the image file (imread), this will be the output from your function im1=imread(img_file); % visualize the image (imshow) imshow(im1); colormap hsv; colorbar; % set the 'userdata' property of the figure object (hfig1) to be the image data (im1) set(Hfig1,'userdata',im1); % add a title to the figure based on the file name (strip the directory from that name) title(fnm); return; %% BMES 202: Code 5_2 %% CODE function imH = ca05_fun2(im1) %%%%%%%%%%%%%%%%%%%%% %% imH = ca05_fun2(im1) %% Convert image to hsv %% plot hue and value images %%%%%%%%%%%%%%%%%%%%% %--- if user did not provide input, extract data from figur object if(nargin<1) hfig1 = findobj('tag','orig-image'); im1=get(hfig1,'userdata'); end %--- convert image from rgb to hsv imH = rgb2hsv(im1); %--- hue im_hue = imH(:,:,1); %--- value im_val = imH(:,:,3); %--- create a new figure, tag it and name it hfig2 = findobj('tag','hue-image'); if(isempty(hfig2)) hfig2 = figure('tag','hue-image','name','Hue Image'); end %--- make new figure active figure(hfig2); %--- create image (using sc) imagesc(im_hue); axis equal tight %--- add colormap and colorbar colormap hsv colorbar %--- add title title('Hue'); set(hfig2,'userdata',imH) %--- create a new figure, tag it and name it hfig3 = findobj('tag','val-image'); if(isempty(hfig3)) hfig3 = figure('tag','val-image','name','Value Image'); end %--- create image (using sc) imagesc(im_val); axis equal tight %--- add colormap and colorbar colormap gray colorbar %--- add title title('Value'); return; %% BMES 202: Code 5_3 %% CODE function imBW = ca05_fun3(imH,h_thr,v_thr); %%%%%%%%%%%%%%%%%%%%% %% imBW = ca05_fun3(imH) %% Create 'masks' based on color %% and 'value' %%%%%%%%%%%%%%%%%%%%% Hfig1 = findobj('tag','orig-image'); Hfig2 = findobj('tag','hue-image'); Hfig3 = findobj('tag','val-image'); Hfig4 = findobj('tag','bw-image'); if(isempty(Hfig4)) Hfig4 = figure('tag','bw-image',... 'Name','Threshold-Image'); hax1 = subplot(1,2,1); set(hax1,'tag','hue-thr', ... 'userdata',[.35,.54;.58,.72]); hax2 = subplot(1,2,2) set(hax2,'tag','val-thr', ... 'userdata',.5); else hax1 = findobj('tag','hue-thr'); hax2 = findobj('tag','val-thr'); end if(nargin<3) if(nargin<2) if(nargin<1) imH = get(Hfig2,'userdata'); end hue_thr = get(hax1,'userdata') prmpt_str(1) = {'Min Green'}; prmpt_str(2) = {'Max Green'}; prmpt_str(3) = {'Min Blue'}; prmpt_str(4) = {'Max Blue'}; def(1) = {num2str(hue_thr(1,1))}; def(2) = {num2str(hue_thr(1,2))}; def(3) = {num2str(hue_thr(2,1))}; def(4) = {num2str(hue_thr(2,2))}; dlg_title = 'Choose Threshold Values'; num_lines = 1; usr_ans = inputdlg(prmpt_str, ... dlg_title, ... num_lines, ... def); hue_thr(1,1) = str2num(char(usr_ans(1))); hue_thr(1,2) = str2num(char(usr_ans(2))); hue_thr(2,1) = str2num(char(usr_ans(3))); hue_thr(2,2) = str2num(char(usr_ans(4))); end clear prmpt_str def usr_ans val_thr = get(hax2,'userdata'); prmpt_str(1) = {'Min Value'}; def(1) = {num2str(val_thr(1,1))}; dlg_title = 'Choose Threshold Values'; num_lines = 1; usr_ans = inputdlg(prmpt_str, ... dlg_title, ... num_lines, ... def); val_thr(1,1) = str2num(char(usr_ans(1))); end %--- first threshold based on hue h1 = imH(:,:,1); v1 = imH(:,:,3); %-- create BW images based on green threshold BWg1 = (h1>hue_thr(1,1) & h1<hue_thr(1,2)); %-- create BW image based on blue threshold BWb1 = (h1>hue_thr(2,1) & h1<hue_thr(2,2)); %--- create BW image based on value threshold BWv = v1>val_thr(1,1); %--- combine BW images BWg2 = BWg1.*BWv; BWb2 = BWb1.*BWv; %--- add to 3d array imBW(:,:,1) = BWg2; imBW(:,:,2) = BWb2; %% Visualize results figure(Hfig4); %--- subplot(1,2,1), Green image axes(hax1); cla imagesc(BWg2); axis equal tight colormap gray title('Green Threshold') set(hax1,'userdata',hue_thr); %--- subplot(1,2,2), Blue image axes(hax2); cla imagesc(BWb2); axis equal tight colormap gray title('Blue Threshold') set(hax2,'userdata',val_thr); set(Hfig4,'UserData',imBW); return; %% BMES 202: Code 5_4 %% CODE function [Sgrn,Sblu] = ca05_fun4(imBW, area_thr) %%%%%%%%%%%%%%%%%%%%% %% [Sred,Sgrn] = ca05b_fun4(imBW) %% this function should perform %% statistics on the black-white images %%%%%%%%%%%%%%%%%%%%%%% hfig4 = findobj('tag','bw-image'); hfig5 = findobj('tag','clr-stats'); if(isempty(hfig5)) hfig5 = figure('tag','clr-stats', ... 'Name','Color Statistics', ... 'userdata', 4); end if(nargin<2) if(nargin<1) imBW = get(hfig4,'UserData'); end area_thr = get(hfig5,'userdata'); prmpt_str(1) = {'Min Value'}; def(1) = {num2str(area_thr(1,1))}; dlg_title = 'Choose Threshold Values'; num_lines = 1; usr_ans = inputdlg(prmpt_str, ... dlg_title, ... num_lines, ... def); area_thr = str2num(char(usr_ans(1))); end %%--- analyze green areas %--- first filter out small objects imBWg = bwareaopen(imBW(:,:,1),area_thr); %--- convert BW image into label image Lgrn = bwlabel(imBWg); %--- get properties of regions Sgrn = regionprops(Lgrn); %---- extract area from structure Garea = cell2mat({Sgrn.Area}); %--- get total area of green Gsum = sum(Garea); %% Analyze Blue Threshold Image imBWb = bwareaopen(imBW(:,:,2),area_thr); %--- convert BW image to label image Lblu = bwlabel(imBWb); Sblu = regionprops(Lblu); Barea = cell2mat({Sblu.Area}); Bsum = sum(Barea); Amx = max([Barea,Garea]); x_bns = [Amx/50:Amx/50:Amx]; hCLR(:,1) = hist(Garea, x_bns); hCLR(:,2) = hist(Barea, x_bns); figure(hfig5); plot(x_bns, hCLR(:,1), 'gx-'); hold on; plot(x_bns, hCLR(:,2), 'bo-'); ylabel('Frequency of Occurence'); xlabel('Area'); out_str(1,1) = {sprintf(['Color\tN-obj\t', ... 'Area-mean\tArea-std\tArea-med'])}; out_str(2,1) = {sprintf(['%s\t%.0f\t', ... '%.2f\t%.2f\t%.2f'],... 'Green', length(Garea), ... mean(Garea), std(Garea), median(Garea))}; out_str(3,1) = {sprintf(['%s\t%.0f\t', ... '%.2f\t%.2f\t%.2f'],... 'Blue', length(Barea), ... mean(Barea), std(Barea), median(Barea))}; disp(char(out_str)) return;
%% MHOMO KADIRI (c)2014
Data Normalization and Variance
%% BMES 202: Code 4_1 %% CODE function [Sgeo, soft_file]= ca04_fun1(soft_file) % (Import & Visualization Function ) % If no soft_file input is given, look to figure object (hfig1) 'filename' property (if it doesn't ...exist, you must create it and set the 'tag' property) for the default file name when hfig1=findobj('tag','soft_file'); if nargin==0 % if statement if isempty(hfig1); % if no input find filename with soft_file [fnm,pth]=uigetfile('.soft','Choose File', fullfile(pwd,'*.soft')); % gets the soft_file soft_file=fullfile(pth,fnm); % combines the file name and path hfig1=figure(1); set(1,'tag','soft_file','filename',fnm);% tagging the figure by its filename else soft_file=get(hfig1,'filename'); [pth,fnm] = fileparts(soft_file); end end %% Req 2. Reading Data % Read the data from the .soft file, using the geosoftread function (contained in the ...bioinformatics toolbox) Sgeo=geosoftread(soft_file); % reading the file and saving into variable Sgeo %% Req 3.Extracting Data % Extract the intensity data from the geo-structure, and take the log (base 10) (dtL) y=Sgeo.Data; % extracting the intensity data from the cell array dtL=log10(y); % taking the log (base 10) of the data and saving to dtL %% Req 4. Visualizing Log Intensity % Visualize the log of the intensity data (dtL) as an image (imagesc), make sure to label ... axes (probe# on y, subject label on x) imagesc(dtL)% creating an visual image of the data xlabel('subject label') ylabel('probe number') % giving x and y labels %% Req 5. Giving title % Indicate which color corresponds to what log-intensity value (colorbar) ... Put the geo structure (Sgeo) into the 'userdata' property of the figure object (hfig1) title(fnm) % giving the image title of just filename %% Req 6. Giving image colorbar colorbar % this allows each color to correspond to its intensity %% Req 7. Setting hfig1 set(hfig1,'userdata',Sgeo) % setting hfig1 userdata property to Sgeo return; %% BMES 202: Code 4_2 %% CODE function [dtLn, normgene_label] = ca04_fun2(Sgeo) % (Normalization-1: minimal variance) % If no input is given, go to the figure object of function 1 (hfig1), and get the geo-structure ...(Sgeo) from the 'userdata' property of figure 1. if nargin==0; hfig1 = findobj('tag','soft_file'); Sgeo = get(hfig1,'userdata'); end %Extract the data ('Data' field) from the geo-structure (Sgeo), take the log10 data = log10(Sgeo.Data); %Extract the gene labels ('Identifier' ? field) from the geo-structure (Sgeo) labels = Sgeo.Identifier; %Calculate the standard deviation (std) in the log10 intensity values across ALL COLUMNS ...(subjects), NOT across ROWS (probes): the result should be a Mx1 vector standev = std(data')'; %Find the minimum standard deviation, and subtract that gene's values [1x10] from all log10 ...intensity values and provide this as the function's output (dtLn) minstd = min(standev); x = standev == minstd; y = find(x); dtLn = data - ones(length(data),1)*data(y,:); %Also, output that gene label of minimum standard deviation as a string (normgene_label) normgene_label = labels(y); %Calculate the average normalized intensity for each group (A-obese, B-lean) (look to the ...field 'ColumnDescriptions' in the geo structure (Sgeo) to determine which group each ...column belongs to), and calculate a histogram (hist) from these group averages. avobese = mean(dtLn(:,1:5),2); avlean = mean(dtLn(:,6:10),2); histmat = [avobese avlean]; %In figure 2 (look for a figure object (hfig2) with the 'tag', 'norm1-fig', ...if it doesn't exist create it) plot the bins, versus frequency of occurrence for ...both A and B groups. (As always label axes) hfig2=findobj('tag','norm1-fig'); if isempty(hfig2) hfig2=figure('tag','norm1-fig'); end hist(histmat); %Title the plot (title) based on the normalization gene. tt=['Normalization gene: ' normgene_label]; title(tt) return; %% BMES 202: Code 4_3 %% CODE function [dtLn, normgene_label] = ca04_fun3(Sgeo) %If no input is given, go to the figure object of function 1 (hfig1), and get the geo-structure ...(Sgeo) from the 'userdata' property of figure 1. if (nargin==0) hfig1=findobj('tag','soft_file') ; Sgeo=get(hfig1,'userdata') ; end %Extract the data from the geo-structure (Sgeo) ('Data' - field), take the log10 dtLn=log10(Sgeo.Data); %Extract the gene labels from the geo-structure (Sgeo) ('Identifier' ñ field) labels=Sgeo.Identifier; %Find the unique genes (unique), and prompt the user to select a control gene based on this ...unique list (listdlg) unq=unique(labels); [a,v] = listdlg('PromptString','Select gene:',... 'SelectionMode','single',... 'ListString',unq); %Find ALL rows for the selected gene, and average the log intensity values for that gene (may ...have to average across MANY probes or a SINGLE probe depending on normalization gene ...selected) gene_dat=Sgeo.Data(a,:); mean_val=log10(mean(gene_dat,2)); %Subtract the average normalization gene from all log10 intensity values and provide this as ...the function's output (dtLn) dtLn=dtLn-mean_val; %Also, output that gene label of user selected normalization gene as a string ...(normgene_label) normgene_label=Sgeo.Identifier(a); %Calculate the average normalized intensity for each group (A-obese, B-lean) (look to the ...field 'ColumnDescriptions' in the geo structure (Sgeo) to determine which group each ...column belongs to), and calculate a histogram (hist) from these group averages. avobese = mean(dtLn(:,1:5),2); avlean = mean(dtLn(:,6:10),2); histmat = [avobese avlean]; %In figure 3 (look for a figure object (hfig3) with the 'tag', 'norm2-fig', if it doesn't exist ...create it) plot the bins, versus frequency of occurrence for both A and B groups. (As ...always label axes) hfig3=findobj('tag','norm2-fig'); if isempty(hfig3) hfig3=figure('tag','norm2-fig'); end hist(histmat); %Title the plot (title) based on the normalization gene. tt=['Normalization gene: ' normgene_label]; title(tt) return %% BMES 202: Code 4_4 %% CODE function [dt_sts] = ca04_fun4(dtLn, gene_lbls, probe_lbls) %(Statistical Analysis) % Run a 2-tailed t-test for each probe (ttest2), comparing groups A and B, and store the ... resulting p-values into a vector for i = 1:length(dtLn) [h,p] = ttest2(dtLn(i,1:5),dtLn(i,6:10)); p_values(i,1) = p; end % Find which rows the p-value vector are significant (<.001) rows = find(p_values<0.001); % For significant probes/genes create a summary matrix (dt_sts, also the funtion output ...which holds: a) A-average, A-stnd-dev, B-average, B-stnd-dev, Aavg ? Bavg, p-value Aavg=mean(dtLn(rows,1:5),2); Astd=std(dtLn(rows,1:5),0,2); Bavg=mean(dtLn(rows,5:6),2); Bstd=std(dtLn(rows,5:6),0,2); dt_sts= [Aavg Astd Bavg Bstd Aavg-Bavg p_values(rows,1)]; % In figure 4 (look for a figure object (hfig4) with the 'tag', 'stat-fig', if it doesn't exist create ...it) plot probe # versus Aavg-Bavg of the SIGNIFICANT probes (use stem rather than plot) hfig4=findobj('tag','stat-fig'); if (isempty(hfig4)) hfig4=figure('tag','stat-fig'); end %plot stem(rows',dt_sts(:,5)); %Aavg-Bavg vs probe number ylabel('Aavg-Bavg'), xlabel('Probe Number'); title('Graph of the Aavg-Bavg vs the probe number'); % For significant genes: format the output for copy & paste (sprintf, disp) such that it has ...the following columns: a) probe label, b) gene label, c) A-average, d) A-stnd.dev, e) ...B-average, f) B-stnd.dev, g) Aavg-Bavg, h) p-value for i=1:numel(rows) % For all of the significant probes, out(i+1, 1) = {sprintf('%s\t%s\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.4f', ... probe_lbls{ rows(i) }, ... gene_lbls{ rows(i) }, ... Aavg(i), ... Astd(i), ... Bavg(i), ... Bstd(i), ... Aavg(i) - Bavg(i), ... p( rows(i) ))}; end return;
%% MHOMO KADIRI (c)2014
Data Manipulation, Visualization and Analysis
%% BMES 202: Code 3_1
%% CODE
function [data, col_labels]= ca03_fun1(txt_file)
%(Import & Visualization Function )
% Look for a figure object with the tag property of 'ang-figure' (findobj)
Hfig=findobj('tag','ang-figure');
% If object does not exists, create a figure object and set the tag property to 'ang-
... figure', and set the filename property to a default value such as '*.txt'
if (isempty(Hfig))
Hfig=figure('tag','ang-figure','filename','*.txt');
end
% If user did not provide input (nargin), get the filename property from the figure
... object and use it as the default file name when prompting the user to select a data
...file (uigetfile).
if nargin==0
[fnm,pth]=uigetfile('*.txt','Choose File',getfile(Hfig,'filename'));
txt_file=fullfile(pth,fnm);
end
% Set the filename property to the name of the txt_file (set)
set(Hfig,'filename',txt_file)
% Read in the numeric data (dlmread).
data=dlmread(txt_file,'\t',2,0);
% Read in line 1 of the file as text (fopen, fgetl, fclose) and split that string into a
...[1x15] cell array to label each column of data (regexp(..., ..., 'split'))
fileID=fopen(txt_file);
raw=fgetl(fileID);
fclose(fileID);
col_labels=regexp(raw,'\t','split');
% In the figure from step 2, plot time versus the HT EleL column. (label axes with
% column labels of step 5)
index=find(strcmp(col_labels,'HT EleL'));
% Use the file name as a figure title, and also output the file name to screen
cla; %clear the axis
plot(data(:,1),data(:,index),'-');
%labels
xlabel(col_labels(1)),ylabel(col_labels(index));
title(txt_file,'Interpreter','none'); %so it doesnt read the underscores and stuff
%
set(Hfig,'Name',txt_file);
disp(txt_file);
return
%% BMES 202: Code 3_2
%% CODE
function[ibe] = ca03_fun2(data, col_labels)
% (Segmentation Function)
% Look for a figure object with the tag property 'trial-indecies' (findobj), if it does
Hfig1=findobj('tag','trial_indices');
if isempty(Hfig1)
Hfig1=figure('tag','trial_indices');% not exists, create a new figure with that tag property.
end
% Ask the user which column to display (listdlg)
[choice,ok]=listdlg('PromtString','Please select a column','SelectionMode','single','liststring',col_labels(2,:));
% Plot row-numbers versus the selected column of data (plot)
cla;
plot(data(:,choice),'-')
xlabel('Row_number'),ylabel(col_labels(choice));
% Prompt the user to select the beginning and ending of each trial (getpts)
uiwait(msgbox('Please select the beginning and end of each trial.'));
[x,y]=getpts(findobj('tag','trial_indices'));
% Overlay the points the user selected (plot)
hold on
plot(x,y,'rx');
% Create a beginning-ending matrix (ibe) [Ntrialsx2], in which column 1 holds
...row #s for the beginning of each trial, and column 2 holds the row #s for the end of each trial.
...(This is also the output from this function)
ibe=round([x(1:2:end) x(2:2:end)]);
return
%% BMES 202: Code 3_3
%% CODE
function dt_new = ca03_fun3(data, ibe) (Analysis Function - uicontrol)
% Look for a figure object with the tag property 'shoulder-rhythm' (findobj), if it
% does not exists, create a new figure with that tag property.
Hfig2=findobj('tag','shoulder_rhythm');
if isempty(Hfig2)
Hfig2=figure('tag','shoulder_rhythm');
end
% In the figure from step 15, plot the ST (x) versus HS (y) angles for the 1st trial,
% label axes and ensure axis are 'equal'
x_vals=data(ibe(1,1),ibe(1,2),6);
y_vals=data(ibe(1,1),ibe(1,2),13);
cla;
plot(x_vals,y_vals);
axis equal;
xlabel('st_angle'),ylabel('HS angle');
% Based on the beginning-ending matrix of fun2 (ibe), ADD a column to the data,
% which indicates the trial number for each row (call it dt_new).
col=zeros(1,length(data));
for i=1:length(data)
col(ibe(i,1),ibe(i,2))=i;
end
dt_new=[data col'];
% Create a cell array which has text like the following for each trial {'Trial ? 1'}, etc
text=cell(1,length(ibe));
for i=length(ibe)
text(i)={['Trial-',num2str(i)]};
end
% Look for an object with the tag property, 'trial-choice', if it does NOT exist, create a
% uicontrol object of with the following properties:
Hui=findobj('tag','trial-choice');
if isempty(Hui)
Hui=uicontrol('style', 'popupmenu', ...
'tag', 'trial-choice', ...
'string',text,...
'value', 1, ...
'callback', 'ca03_fun4', ...
'userdata', dt_new);
else set(Hui,'value',1,...
'userdata',dt_new);
end
return
%% MHOMO KADIRI (c)2014

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Excel Data Manipulation
%% BMES 202: code 2_1
%% CODE
function [data, c_head, csv_file]= ca02_fun1(csv_file)
% If user does not provide an input file name (nargin), prompt the user to select a csv file [uigetfile]
...and create a variable to hold the full file name (file name as a function output (csv_file [1xN] character array)).
if nargin == 0
[filename, path]=uigetfile('*.csv','Choose file','AG_1p_test1.csv');
csv_file=fullfile(path, filename);
end
% Read in the data [csv_read] (data Mx3 numeric array) and the header information
...(c_head [2x1] cell array) [fopen, fgetl, fclose, !! can't use uiimport], and provide these as function outputs.
data=csvread(csv_file,2,0);
fileID=fopen(csv_file,'rt');
fgetl(fileID);
c_head(1,1)={fgetl(fileID)};
c_head(2,1)={fgetl(fileID)};
fclose(fileID);
% In figure1, visualize the raw data (time vs load, time vs displacement) [plot, subplot]
figure(1);
subplot(2,1,1);
plot(data(:,1),data(:,2),'-')
xlabel('Time (sec)'), ylabel('Force (N)'), title('Time (sec) vs Force (N)')
subplot(2,1,2);
plot(data(:,1),data(:,3),'-')
xlabel('Time (sec)'), ylabel('Displacement (mm)'), title('Time (sec) vs Displacement (mm)')
return;
%% BMES 202: code 2_2
%% CODE
function [dt_hold] = ca02_fun2(data)
% Create a new figure (figure 2), and plot time versus load (make sure load is positive)
figure(2)
plot(data(:,1),data(:,2),'-');
xlabel('Time (sec)'), ylabel('Load (N)');
title('Time (sec) vs Load (N)');
% Prompt the user (msgbox, uiwait) to select the beginning of the hold [ginput]
uiwait(msgbox('Please select the beginning of the hold'));
[x y]=ginput(1);
% Find the rows of the hold data based on the point the user selected [find]
rows=find(data(:,1)> x & -data(:,2)> y);
% Create an output variable which holds the data in only the rows from step 8 (dt_hold)
dt_hold=data(rows,:);
% Overlay the 'hold' data to figure 2.
figure(2)
hold on
plot(dt_hold(:,1),-dt_hold(:,2)),'r-')
return;
%% BMES 202: code 2_3
%% CODE
function [fit_parms, d_err] = ca02_fun3(dt_hold)
%(Analysis Function)
% In a new figure (figure 3), plot the time vs displacement data (be sure to 'shift' the time data so that
...it starts at 0, and displacement is positive)
figure(3);
dt_new=dt_hold-dt_hold(1);
plot(dt_new(:,1),-dt_new(:,3),'-');
xlabel('TIme (sec)'), ylabel('Displacement (mm)')
% Set the upper and lower limits on the parameters for your equation
ul=dt_new(1); %upper limit
ll=dt_new(end,1); %lower limit
% Set the initial guess for the parameters a, b, c
a=-dt_new(1,3); %at t=0 and y=a
b=-dt_new(end,3)-(-dt_new(1,3)); %scaling factor: last-first value
max_tc=a+0.632*b;
%The time that fits this description
possible_values=find(-dt_new(:,3)>max_tc*(1-1e-4) & -dt_new(:,3)<max_tc*(1+1e-4));
%therefore
c=dt_new(possible_values(1),1);
% Fit the equation to the 'hold' displacement/time data [lsqcurvefit] and provide the
...best-fit parameters as outputs of your function.
fit_parms=lsqcurvefit(@creep_fun1 ,[a b c], dt_new(:,1), -dt_new(:,3), [0 0 0], 1.5*[a b c]);
y_data= fit_parms(1)+fit_parms(2)*(1-exp(-dt_new(:,1)/fit_parms(3)));%from the equation given
%plot
hold on;
plot(dt_new(:,1),-y_data,'ro')
% Calculate the estimated displacement from the best-fit parameters, and overlay that data onto figure 3.
% Calculate the error of the fit (difference in estimate and actual displacement) [diff]
d_err=diff([y_data -dt_new(:,3)],2);
return
%% BMES 202: code 2_4
%% CODE
function ca02_fun4()
% Call functions 1-3 in sequence
[data, c_head, csv_file]= ca02_fun1();
[dt_hold] = ca02_fun2(data);
[fit_parms, d_err] = ca02_fun3(dt_hold);
% Calculate the root-mean-square error (RMSE)
rmse = rms(d_err)
% Take the output from functions 1-3, and format the following parameters
% to screen for copy & paste (sprintf, disp): 'Filename, a(mm), b (mm), c
% (sec), RMSE' (RMSE is root-mean-square-error)
[pth name ext] = fileparts(csv_file);
out(1, 1) = {sprintf('%%Filename\ta(mm)\tb(mm)\tc(sec)\tRMSE')};
% The first line of the output file sets up the headers for the variables
% that are being reported in addition to their units. They are formatted
% using sprintf.
out(2, 1) = {sprintf('%s\t%.2f\t%.2f\t%.2f\t%.4f', [name ext], ...
fit_parms(1), fit_parms(2), fit_parms(3), rmse)};
% The second line of the output file prints the filename and other
% variables with the desired number of significant figures.
char(out) % The output is converted to characters and ready for
% copy-and-paste to Excel.
return
%%MHOMO KADIRI (c)2014
Data Import and Visualization
%% BMES 202: Code 1_1 %% CODE (Import & Visualization Function) function [data, c_head, filename]= ca01_fun1() % graphic user interface which allows the user to select the *.dat file to be analyzed [uigetfile], ...also this will be an output variable (filename [1xN] string array) from your function [filename, path]=uigetfile('*.dat','Choose Input File'); raw_data=uiimport(fullfile(path,filname)); % Read BOTH the numerical data (Mx3 matrix) and header information from the *.dat file [uiimport] data=raw_data.data; c_head=raw_data.colheaders; % Provide the numeric data as an output variable (data [Mx3 numerical array] % Using the units from the header information (?colheader? field) and the information contained in the header(time, displacement, load) ...to output the a cell array holding the variable and units for each column of data (c_units [1x3 cellular array]) from your function. % Create a figure (figure.1) and plot BOTH time (x-axis) vs force (y-axis) and time (x-axis) vs displacement (y-axis) ...mislabeled figures will -.3 pts figure(1) subplot(2,1,1); plot(data(:,1),data(:,2),'r-'); xlabel('Time (sec)'), ylabel('Displacement (mm)'); title('Displacement vs Time') subplot(2,1,2) plot(data(:,1),data(:,3),'b-'); xlabel('Time (sec)'), ylabel('Force (N)'); title('Force vs Time') return; %% BMES 202: Code 1_2 %% CODE (Segmentation Function) function pts_mnmx = ca01_fun2(data) % In a new figure (figure.2), plot displacement (x-axis) versus load (y-axis) (always label your axes) from the input variable (data, [Mx3] numeric array) % load and displacement are negative, you must invert them so that they are positive figure(2) plot(-data(:,1),-data(:,3),'g-'); xlabel('Displacement (mm)'), ylabel('Load (N)') title('Displacement versus Load') % Prompt the user [uiwait, msgbox] to select two points which define the 'linear' region [getpts], % and overlay those points onto figure 2. uiwait; msgbox('Select two points that define the Linear Regions','Select Points'); [x,y]=getpts(2); pta_mnmx=sort([x,y]); %ENSURE x(1) is < x(2) and y(1) < y(2)!! uiresume(2); %Output a variable (pts_mnmx [2x2] numerical array) which holds the two selected points from your function. return; %% BMES 202: code 1_3 %% CODE (Analysis Function) function k_bone = ca01_fun3(data, pts_mnmx) % Find the row #s and put them into a new variable (rows_linear, Max1) within the data matrix that are bounded by the minimum ...and maximum x & y values defined by function 2 (the variable pts_mnmx), [find]. * load and displacement are negative, ...you must invert them so that they are positive rows_linear=find(-data(:,2)>pts_mnmx(1) & -data(:,2) <pts_mnmx(2) & -data(:,3)>pts_mnmx(3) & -data(:,3)<pts_mnmx(4)); % Create a new variable, (dt_linear) which has only the data for the rows of step 7 (rows_linear), and fit a line ...through the displacement (x-axis) and force (y-axis) data [polyfit]. dt_linear=data(rows_linear,:); poly=polyfit(-dt_linear(:,2),-dt_linear(:,3),1); % Provide this slope as an output variable (k_bone [1x1] number) of your function, and in figure 2 (figure.2), ...overlay a plot of this linear estimate for load [polyval]. k_bone=poly(1); figure(2); hold on values=polyval(poly,dt_linear(:,2)); plot(-dt_linear(:,2), values,'ro'); return; %% BMES 202: Code 1_4 function ca01_fun4() % Call functions 1-3 in sequence, and report the following: filename, x1, % y1, x2, y2, slope to the command window, for easy COPY & PASTE into excel % [sprintf, disp, char] [data, c_head, filename]= ca01_fun1(); pts_mnmx = ca01_fun2(data); k_bone = ca01_fun3(data, pts_mnmx); out(1, 1) = {sprintf('%%Filename\tx1(mm)\ty1(mm)\tx2(mm)\ty2(mm)\tk_bone(N/mm)')}; % The first line of the output file sets up the headers for the variables % that are being reported in addition to their units. They are formatted % using sprintf. out(2, 1) = {sprintf('%s\t%.2f\t%.1f\t%.2f\t%.1f\t%.3f', filename, ... pts_mnmx(1), pts_mnmx(3), pts_mnmx(2), pts_mnmx(4), k_bone)}; % The second line of the output file prints the filename and other % variables with the desired number of significant figures. char(out) % The output is converted to characters and ready for % copy-and-paste to Excel. return; Result Formated output: <filename>, <x(1), y(1), x(2), y(2)>, <k_bone> %Filename x1(mm) y1(mm) x2(mm) y2(mm) k_bone(N/mm) E4_S062_G02_F3.dat 1.83 19.4 3.46 218.9 124.072
%% MHOMO KADIRI (c)2014
Hello
Hi,
I am currently taking the next class in the BMES programming and modeling series (BMES 201).
As a result, the problems will be harder. I will try to keep my solutions as basic as possible, in the hopes that my readers will have a better and clearer understanding of the material.
Enjoy.
ResolveSample
This code was an assignment for my Biomedical Engineering Seminar Programming Class.
%% RESOLVE SAMPLES % It Reads in the referencesequences.txt file given above. (Using myfastaread() function). % Calculates the codon usage counts for each Mus musculus (mouse) reference sequence (using getcodonusage()) and adds the count vectors to construct a single codonusage1 variable. % Repeats the same for the Drosophila melanogaster (fruit fly) sequences to construct codonusage2 variable. % Reads in each of the sequences in the querysequences.txt file (using myfastaread() function), finds which species each query sequence is coming from (using pickcodonusage()), and prints whether each one is from a mouse or from a fruit fly. %% Fastaread function %% Read the files % Refrences r=myfastaread('referencesequences.txt'); q=myfastaread('querysequences.txt'); % Initialize the zero vecors mouseusage=zeros(1,64); flyusage=zeros(1,64); % For each reference sequence as r [r1,r2,r3,r4,r5]=r.Sequence; [q1,q2]=q.Sequence; [rcodon,~]=getcodonusage(r1); % For-loop for k=1:64 if ~isempty((strfind({r.Header},'Mus musculus'))) mouseusage(k)=rcodon(k); else flyusage(k)=rcodon(k); end end % For-loop for i=1:64 [qusage,~]=getcodonusage(q1); result=pickcodonusage(mouseusage,flyusage,qusage); if result==1 fprintf('Sequence %d is from a mouse\n',i) elseif result==2 fprintf('Sequence %d is from a fly\n',i) end end
%% MHOMO KADIRI (c)2013
Pickcodonusage
function [ result ] = pickcodonusage( codonusage1,codonusage2,codonusage )
% It returns 1 if codonusage is more similar to codonusage1 than it is to codonusage2, otherwise it returns 2.
% Normalize the codonusages. Then resolve them into frequency vectors p
% and q.
p=codonusage1./sum(codonusage1);
q=codonusage2./sum(codonusage2);
r=codonusage./sum(codonusage);
% Find the distances between the codon points using a subfunction
function [ dprime ] = codondistance( a,b )
% Euclidean Distance function
for i=1:64
d=sum(((a(i)-b(i))^2));
end
dprime=sqrt(d);
end
% d1=distance between codonusuage1 and codonusuage
% d2=distance between codonusuage2 and codonusuage
d1=codondistance(p,r);
d2=codondistance(q,r);
% Condition for output using if loop
if d1<d2
result=1;
else result=2;
end
end
%% MHOMO KADIRI (c)2013

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Getcodonusage
function [ codonusagevector, codonusagestruct ] = getcodonusage( s )
%It takes a DNA strand s as input, calls the findorf(s) function to find the ORF, and returns the codon usage of the sequence as both a vector
% (each element corresponding to the count of a codon, where codons are in alphabetical order) and as a struct with each codon as a field,
% and its count as the number of occurence of that codon
%v=codon count vector
%r=codon count struct
allcodons=getallcodons();
%initialize the vector v
v=zeros(1,numel(allcodons));
%initalize the struct r
r=struct('string',{allcodons},'cod',{});
[r.cod]==0;
%Find orf
orf=findorf(s);
%for loop to iterate the vector and field
for k=1:numel(allcodons)
i=sum(strcmp(orf,allcodons{k}));
v(k)=i;
u.(allcodons{k})=i;
end
%output
codonusagevector=v;
codonusagestruct=u;
%Add the provided functions (findorf and getallcodons) so that the function is self-contained
%% Findorf
function [ o ] = findorf( s )
%s='ATTAATGCATTTTTAGGAATA';
starts = strfind(s,'ATG');
stops=[strfind(s,'TAA') strfind(s,'TAG') strfind(s,'TGA')];
if isempty(starts); starts=1; end
orfs=zeros(0,2);
for mystart=starts
I=(stops > mystart) & (mod(stops - mystart, 3)==0);
mystops = stops(I);
if isempty(mystops); mystops=numel(s); end
mystop = mystops(1);
orfs(end+1,:) = [ mystart mystop];
end
lengths = orfs(:,2) - orfs(:,1);
[maxlen, I] = max(lengths);
startstop=orfs(I,:);
o = {};
for i=startstop(1) : 3 : startstop(2)
if (i+2) <= numel(s)
o{end+1} = s(i:i+2);
end
end
end
%% Getallcodons
function [ cods ] = getallcodons( input_args )
%The getallcods function
cods = {};
for i=['A' 'C' 'G' 'T']
for j='ACGT'
for k='ACGT'
cods{end+1} = [i j k];
end
end
end
end
end
%% MHOMO KADIRI (C)2013
PDB_bfactor
function [ value ] = pdb_bfactor( x )
%It takes a four letter PDB identifier and returns the average B factor of all of the CA (alpha carbon) atoms.
%Download the pdb file from pdb.org website, e.g., if the PDB id "1crn" is given as input, you can download the protein file from http://www.pdb.org/pdb/files/1crn.pdb .
%Download the file using URL string concatenation
urlname=strcat('http://www.pdb.org/pdb/files/',x,'.pdb');
filename=strcat(x,'.pbd');
if ~exist(filename,'file')
urlwrite(urlname,filename)
end
%Open the Pbd file for reading
fid=fopen(filename,'r'); %open file
value=zeros(0,1); %create a placholder
%while loop
while ~feof(fid)
line=fgetl(fid);
%Conditions and paramaters
if strncmp(line,'ATOM',4);
type=line(13:16);
type(type==' ')=[];
if strcmp(type,'CA');
bfactor=str2double(line(61 :66));
value(end+1,:)=[bfactor];
end
end
end
value=sum(value)/numel(value);
fclose(fid); %close file
end
%% MHOMO KADIRI (c)2013