Syntax error for Calcium imaging analyses code: I am trying to implement Ca2+ analyses pipeline but there is a following syntax error:

1 visualizzazione (ultimi 30 giorni)
function [ROI_intensity1, c, r]=(1,'LS002.tif','Fluo',6);
Error: File: GCamp6.m Line: 1 Column: 41
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
In the above code: 1 =time interval; LS002.tif=refers to my timelapse file; Fluo= figure legent; 6 refers to the neuron diameter.

Risposte (1)

Voss
Voss il 12 Apr 2022
Define the function like this:
function [ROI_intensity1, c, r] = GCamp6(time_interval, timelapse_file, legend_name, neuron_diameter)
% use time_interval, timelapse_file, legend_name, neuron_diameter
% (change those variable names to match what you are already using
% inside your function) to calculate ROI_intensity1, c, r
%
% (your code goes here)
%
end
Somewhere else, call the function like this:
[ROI_result, c_result, r_result] = GCamp6(1,'LS002.tif','Fluo',6)
% change ROI_result, c_result, r_result to whatever you want / whatever is
% convenient for any subsequent code that uses these results from GCamp6
  2 Commenti
Yojet Sharma
Yojet Sharma il 12 Apr 2022
Thanks!
It seems like it solved this problem. Can you please check if I did it correctly (I'm a newbie to matlab)?
Another thing that I forgot to mention was that there's another parameter here "varargin", which the authors mention that it needs to be left blank (described below). And so when I leave this blank now (as seen in the screenshot above) it gives me the following error:
Out of memory. The likely cause is an infinite recursion within the program.
Error in GCamp6 (line 2)
[ROI_result, c_result, r_result] = GCamp6(1,'LS002.tif','Fluo',6)
About the code:
III-a GCAMP_multiROI.m
Note the variables in the function are:
  • timerinterval = the frame rate in second.
  • name1 = the COMPLETE file name of the tiff image stack you are going to analyse.
  • legend1 = the figure legend you want to put.
  • diameter = the diameter of ROI in micrometer - it is roughly the cell diameter.
  • varargin = leave this blank as it will automatically save all the parameters in a matrix.
To run the "GCAMP_multiROI.m" function, see an example here:
to analyse a file named 'neuron.tif' which has time interval of 20 msec and the neuron soma diameter is 6um, the function should be:
GCAMP_1_multiROIplot(0.02,'neuron.tif’,’GCaMP intensity',6).
Upon running the function, it takes 10-30 sec to prompt an image which is the maximum intensity projection of the image stack, then select the ROI/cells on this image you want to analyse, then press Enter key to finish all the selections.
The function will calculate intensity profile of each cells and its coordinate all saved in the file named ROI_intensity1.mat. Each column is one cell, and each the row is the intensity at each time point.
Voss
Voss il 12 Apr 2022
OK, I think I understand the situation now: You have a function (maybe it's called GCamp6, maybe it's called GCAMP_multiROI, maybe it's called GCAMP_multiROIplot) and you want to call this function with a particular sets of inputs.
In that case (let's say the function is called GCAMP_1_multiROIplot), you can put the following command in some other m-file or on the MATLAB command line:
[ROI_result, c_result, r_result] = GCAMP_1_multiROIplot(1,'LS002.tif','Fluo',6);
This will run GCAMP_1_multiROIplot with timerinterval=1, name1='LS002.tif', legend1='Fluo', and diameter=6. And the results are stored in the variables ROI_result, c_result, r_result.
[IMPORTANT: undo any changes you might have made to GCAMP_1_multiROIplot.m (or whatever it's called) or download a new copy.]
Originally, I thought you were defining your own function GCamp6. If that's the case, here's my advice:
Let's say that file you showed is called GCamp6.m. Then the file should start with this, to define the function:
function [ROI_intensity1, c, r] = GCamp6(timerinterval, name1, legend1, diameter, varargin)
You have done that correctly, except the input argument names needed to be changed to match the homework assignment description (which I have done here).
Then all the remaining lines in the file should be your calculation of ROI_intensity1, c, and r, from timerinterval, name1, legend1, diameter. For example:
function [ROI_intensity1, c, r] = GCamp6(timerinterval, name1, legend1, diameter, varargin)
% NOT REAL equations, just an example
ROI_intensity1 = diameter*timerinterval+1;
c = sqrt(diameter);
r = sqrt(-diameter);
end
Then, somewhere else outside the file GCamp6.m, e.g., in another file or on the command line, in order to call the function GCamp6 with some particular inputs, you say:
[ROI_result, c_result, r_result] = GCamp6(1,'LS002.tif','Fluo',6)
In this case, GCamp6 is run with timerinterval=1, name1='LS002.tif', legend1='Fluo', and diameter=6. And the results are stored in the variables ROI_result, c_result, r_result.
The way you have it now, the second line of GCamp6.m (calls GCamp6 itself, which in turn calls it again, which in turn calls it again, and so on, so you get the "infinite recursion" error - nothing to do with varargin).
More information about using functions in MATLAB: https://www.tutorialspoint.com/matlab/matlab_functions.htm

Accedi per commentare.

Categorie

Scopri di più su Neuromicroscopy in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by