123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- function ampAtStim_curveset(files, varargin)
- %% Amplitude during a stimulation analysed over the trials
- % This function helps to analyse time effects on the amplitude of the
- % membrane potential during stimulation. The amplitude values are obtained
- % from the 'ampAtStim' function and are plotted with one curve per trial.
- % -------------------------------------------------------------------------
- % Input [additional arguments are positional,
- % ----- optional arguments are name-value pairs]
- %
- % files: ID of the datafile(s) in the data directory
- % type: integer or vector
- % Trials: select the trials which should be used. Default: 'all'
- % (additional) type: integer or vector
- % Filter: select between three filter options:
- % (optional) 'hn' applys a hum-noise-remove filter
- % 'hnhfn' additonally applys a low pass filter to remove
- % high frequency noise
- % If not set, it will be set to "no" (default).
- % StimCell: set whether to plot the data for a stimulated T-cell ('T')
- % (optional): or a stimulated interneuron ('INT'). Default: 'T'
- %
- % ------
- % Output
- % ------
- % visually output of the plot(s)
- % -------------------------------------------------------------------------
- % Program by: Bjarne Schultze [last modified 09.03.2022]
- % -------------------------------------------------------------------------
- %% Preperations
- % parse the user input
- [file_num, trials, filter_choice, ~, ~, stimCell, ~,~,~] = ...
- parse_input_peakfun(files, varargin{:});
- % load a file with different colors
- load("../AdditionalFiles/colorShades.mat", 'colorShades');
- load("../AdditionalFiles/standard_stimulus.mat", "standard_stimulus");
- % obtain the amplitudes for the requested files
- amps = ampAtStim(file_num, 'Filter', filter_choice);
- % obtain the amplitudes of the current pulses
- [stim_peaks, ~] = findpeaks(standard_stimulus, 10000);
- % find negative stimului (therefor inverting the stimulus data)
- [min_stim_peaks, ~] = ...
- findpeaks(-standard_stimulus, 10000, 'MinPeakHeight', 0);
- % invert the peak values back
- min_stim_peaks = -min_stim_peaks;
- % concatenating positive and nagative stimlus peak data
- all_stim_peaks = [min_stim_peaks; stim_peaks];
- % sort the values for the current in ascending order
- all_stim_peaks = sort(all_stim_peaks);
- %% Plot the results
- for file = 1:length(file_num)
- trial_num = size(amps{file,1}.AmplitudeT,2);
- % select the trials according to the stimulated cell (stimCell)
- if isequal(stimCell, "INT")
- stimulated = setdiff(1:trial_num, amps{file,1}.stimulatedT, ...
- 'stable');
- plot_title = sprintf("File: %02.f - Interneuron stimulated", ...
- file_num(file));
- else
- stimulated = amps{file,1}.stimulatedT(:);
- plot_title = sprintf("File: %02.f - T-cell stimulated", ...
- file_num(file));
- end
- % if requested, select only certain trials
- if ~isequal(trials, 'all')
- stimulated = intersect(trials, stimulated);
- end
-
- % check if there are trials selected for which the data can be plotted
- if ~isempty(stimulated)
- % plot the data for the first selected trial
- figure('Position',[120,67,1278,694]);
- plot(all_stim_peaks, amps{file,1}.AmplitudeT(:,stimulated(1)), ...
- '-o', 'Color', colorShades.blue(1,:))
- hold on;
- plot(all_stim_peaks, amps{file,1}.AmplitudeINT(:,stimulated(1)), ...
- '-o', 'Color', colorShades.red(1,:));
- title(plot_title);
- xlabel("stimulation current [nA]");
- ylabel("amplitude of the membrane potential [mV]");
- yline(0, 'Color', [0.6 0.6 0.6])
- legend("T-cell", "Interneuron", 'Location','best', ...
- 'AutoUpdate','off');
-
- % plot the data for all the other trials, each with a brighter
- % color shade
- for col = 2:length(stimulated)
- % if not enough color shades are available, all later trials
- % get the birghtest shade
- if col > length(colorShades.blue(:,1))
- plot_colorT = colorShades.blue(end,:);
- plot_colorINT = colorShades.red(end,:);
- else
- plot_colorT = colorShades.blue(col,:);
- plot_colorINT = colorShades.red(col,:);
- end
- plot(all_stim_peaks, ...
- amps{file,1}.AmplitudeT(:,stimulated(col)), '-o', ...
- 'Color', plot_colorT)
- plot(all_stim_peaks, ...
- amps{file,1}.AmplitudeINT(:,stimulated(col)), '-o', ...
- 'Color', plot_colorINT);
- end
- hold off;
- else
- % display an error message when there was no trial to plot
- fprintf("\nBad trial selection for file %g. No plot created!\n", ...
- file_num(file));
- end
- end
- % end of function definition
- end
|