File: PrintPhotoreceptors.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (131 lines) | stat: -rw-r--r-- 6,196 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
function PrintPhotoreceptors(photoreceptors)
% PrintPhotoreceptors(photoreceptors)
%
% Print to command window an interpretable output
% of what is in a photoreceptors structure.
%
% See also DefaultPhotoreceptors, FillInPhotoreceptors.
%
% 7/19/13  dhb  Wrote it.
% 8/12/13  dhb  Code more generally and get rid of some special cases.
%          dhb  For cmf-like spectral functions, print out peak wavelengths and peak values.
% 10/16/13  mk  fields() -> fieldnames() for Octave compatibility. Other
%               bug fixes, e.g., wrong use of ii for innermost for-loops.

theFields = fieldnames(photoreceptors);
for ii = 1:length(theFields);
    theField = theFields{ii};
    switch (theField)
        case 'species'
            % Print out species that parameters are extracted for
            fprintf('  * Photoreceptor species: ''%s''\n',photoreceptors.species);
            
        case 'types'
            % List the names of the photoreceptor types
            fprintf('  * Photoreceptor types:\n');
            for jj = 1:length(photoreceptors.types)
                fprintf('    * %s\n',photoreceptors.types{jj});
            end
            
        case 'nomogram'
            % Have to special case this one
            fprintf('  * Photoreceptor field %s\n',theField);
            fprintf('    * Wavelength sampling: %d nm start, %d nm step, %d samples\n', ...
                photoreceptors.nomogram.S(1), photoreceptors.nomogram.S(2), photoreceptors.nomogram.S(3));
            if (isfield(photoreceptors.nomogram,'source') && ~strcmp(photoreceptors.nomogram.source,'None'))
                eval(['theNumberTypes = length(photoreceptors.' theField '.lambdaMax);']);
                eval(['theSource = photoreceptors.' theField '.source;']);
                fprintf('    * Source: ''%s'', value for each photoreceptor type: ',theSource);
                for jj = 1:theNumberTypes
                    fprintf('%g nm ',eval(['photoreceptors.' theField '.lambdaMax(jj)']));
                end
                fprintf('\n');
            end
            
        case {'absorbance' 'absorptance' 'effectiveAbsorptance' 'isomerizationAbsorptance' 'energyFundamentals' 'quantalFundamentals'}
            eval(['theCmf = photoreceptors.' theField ';']);
            [peakWls, peakVals] = FindCmfPeaks(photoreceptors.nomogram.S,theCmf);
            fprintf('  * Photoreceptors field %s\n',theField);
            fprintf('    * Spectral peaks at:');
            for jj = 1:length(peakWls)
                fprintf(' %d',peakWls(jj));
            end
            fprintf('\n');
            fprintf('    * Values at peaks:');
            for jj = 1:length(peakVals)
                fprintf(' %0.4f',peakVals(jj));
            end
            fprintf('\n');
            
        case {'lensDensity' 'macularPigmentDensity' 'preReceptoral'}
            % Print just source for these fields
            fprintf('  * Photoreceptors field %s\n',theField);
            hasSource1 = eval(['isfield(photoreceptors.' theField ',''source'');']);
            if (hasSource1)
                hasSource2 = eval(['~isempty(photoreceptors.' theField '.source);']);
                if (hasSource2)
                    eval(['theSource = photoreceptors.' theField '.source;']);
                    fprintf('    * Source: ''%s''\n',theSource);
                    hasValue0 = eval(['~strcmp(photoreceptors.' theField '.source,''None'');']);
                end
            end
            hasTrans1 = eval(['isfield(photoreceptors.' theField ',''transmittance'');']);
            if (hasTrans1)
                hasTrans2 = eval(['~isempty(photoreceptors.' theField '.transmittance);']);
                if (hasSource2)
                    eval(['theCmf = photoreceptors.' theField '.transmittance;']);
                    [peakWls, peakVals] = FindCmfPeaks(photoreceptors.nomogram.S,theCmf);
                    fprintf('    * Spectral peaks at:');
                    for jj = 1:length(peakWls)
                        fprintf(' %d',peakWls(jj));
                    end
                    fprintf('\n');
                    fprintf('    * Values at peaks:');
                    for jj = 1:length(peakVals)
                        fprintf(' %0.4f',peakVals(jj));
                    end
                    fprintf('\n');
                end
            end
            
        case {'ageInYears' 'fieldSizeDegrees'}
            % Just a numeric field, but don't print value if is empty
            eval(['theValue = photoreceptors.' theField ';']);
            if (~isempty(theValue))
                fprintf('  * Photoreceptors field %s: %g\n',theField,theValue);
            end
            
        otherwise
            % Other theFields are source/value pairs, print generically.
            % Sometimes one of the fields is not there or empty, in which
            % case just print the other.
            fprintf('  * Photoreceptors field %s\n',theField);
            hasSource1 = eval(['isfield(photoreceptors.' theField ',''source'');']);
            if (hasSource1)
                hasSource2 = eval(['~isempty(photoreceptors.' theField '.source);']);
                if (hasSource2)
                    eval(['theSource = photoreceptors.' theField '.source;']);
                    fprintf('    * Source: ''%s''\n',theSource);
                    hasValue0 = eval(['~strcmp(photoreceptors.' theField '.source,''None'');']);
                else
                    hasValue0 = true;
                end
            else
                hasValue0 = true;
            end
            
            hasValue1 = eval(['isfield(photoreceptors.' theField ',''value'');']);
            if (hasValue1)
                hasValue2 = eval(['~isempty(photoreceptors.' theField '.value);']);
                if (hasValue2 && hasValue0)
                    eval(['theValue = photoreceptors.' theField '.value;']);
                    fprintf('    * Value:');
                    valDim = length(theValue);
                    for jj = 1:valDim
                        fprintf(' %0.4g',theValue(jj));
                    end
                    fprintf('\n');
                end
            end
    end
end