%% License Info
%A Model of Feedforward, Global, and Lateral Inhibition in the Locust Visual System.
%This model examines the architecture and function of inhibitory mechanisms in the
%visual system of locusts, namely those involved in the processing of inputs to a
%key looming-sensitive neuron, the lobula giant movement detector (LGMD).
%Copyright (c) 2026, Erik Olson, Travis Wiens, and Jack Gray
%CITATION:
%When using the model code for scientific publications, cite the following work:
%Olson EGN, Wiens TK, Gray JR. A model of feedforward, global, and lateral inhibition
%in the locust visual system predicts responses to looming stimuli. Biol Cybern. 2021
%Jun;115(3):245-265. doi: 10.1007/s00422-021-00876-8. Epub 2021 May 16. PMID: 33997912.
%This program is free software: you can redistribute it and/or modify
%it under the terms of the GNU General Public License as published by
%the Free Software Foundation, either version 3 of the License, or
%(at your option) any later version.
%This program is distributed in the hope that it will be useful,
%but WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%GNU General Public License for more details.
%You should have received a copy of the GNU General Public License
%along with this program. If not, see <https://www.gnu.org/licenses/>.
%Contact: erik.olson@usask.ca
%% Code
function [V_out,t_out] = LMCTrialFunction(parFile)
%Generates LMC responses to a luminance change over the corresponding
%ommatidium. The recording site is proximal to the SIZ. Results are
%generated for four different luminance change durations: 0 ms, 83 ms,
%183 ms and 350 ms. Inputs:
%parfile = name of the parameter file containing model parameters
%Outputs:
%V_out = the voltage traces for each stimulus duration [V]. Each column
%corresponds to a single stimulus duration, going from shortest to longest,
%left to right
%t_out = the corresponding time values [s]
load(parFile);
options = simset('srcworkspace','current','ReturnWorkspaceOutputs','on');
results = sim("LMCTrial.slx",0.449,options);
t_out = results.yout{1}.Values.Time; %Access time data
y1 = results.yout{1}.Values.Data; %Access dendritic branch current data
y2 = results.yout{2}.Values.Data;
y3 = results.yout{3}.Values.Data;
y4 = results.yout{4}.Values.Data;
Simulink.sdi.clear;
V_out = [y1,y2,y3,y4];
end