Skip to content
This repository has been archived by the owner on Feb 13, 2018. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
- update of the README file
  • Loading branch information
mattberjon committed Jan 6, 2016
1 parent 607f237 commit ad8e50e
Show file tree
Hide file tree
Showing 64 changed files with 12,798 additions and 0 deletions.
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2013, Matthieu Berjon and others.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# MbOct

This project has been developed within the Action and Perception group of the school of
Psychology at Cardiff University. A new audiovisual lab has been created and needed a bit
of code in order to be analyse the data provided by the measurements and simulations.
[Octave][1] has been chosen for several reasons:

* Open source software
* Good compatibility with Matlab (used inside the Lab)
* Good toolboxes for signal processing

Please, download it, study it, improve it and share it!

## Installation

Copy the files in your home folder ~/ and edit the ~/Octave file by adding the following line:

~~~.{bash}
addpath('<directory/where/are/stored/the/files')
~~~

## License

Please refer to the LICENSE file at the root of the project.

## Contributing

We’re really happy to accept contributions from the community, that’s the main reason why
we open-sourced it! There are many ways to contribute, even if you’re not a technical person.

We’re using the infamous [simplified Github workflow][2] to accept modifications (even internally),
basically you’ll have to:

* create an issue related to the problem you want to fix (good for traceability and cross-reference)
* fork the repository
* create a branch (optionally with the reference to the issue in the name)
* hack hack hack
* commit incrementally with readable and detailed commit messages
* submit a pull-request against the master branch of this repository

We’ll take care of tagging your issue with the appropriated labels and answer within a week
(hopefully less!) to the problem you encounter.

If you’re not familiar with open-source workflows or our set of technologies, do not hesitate to ask
for help! We can mentor you or propose good first bugs (as labeled in our issues). Also welcome to
add your name to Credits section of this document.


### Submitting bugs

You can report issues the issue tracker of the [project][4], that would be a really useful contribution given that we lack
some user testing on the project. Please document as much as possible the steps to reproduce your problem
(even better with screenshots).


## Credits

* [Matthieu Berjon][1]
* All the contributors of Pure Data



[1]: https://www.gnu.org/software/octave/
[2]: http://scottchacon.com/2011/08/31/github-flow.html
[3]: https://berjon.net/matt
[4]: https://berjon.net/projects/mboct
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
20 changes: 20 additions & 0 deletions analysis/ComputePsychFunc.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function [param good_ans_perc] = ComputePsychFunc(data, answer_comp)
% function [param good_ans_perc] = ComputePsychFunc(data, answer_comp)
% compute the psychometric function for one parameter based on a 2AFC. The
% parameters has to be the first the first column, the answer on the second
% column.

[b, id] = sort(data(:, 1));
data_sort = data(id, :);

% for each speed, we count the number of trials
param = unique(data_sort(:, 1));
for a = 1:length(param)
nb_trials_per_param = length(find(data_sort(:, 1) == param(a)));
ids = find(data_sort(:, 1) == param(a));
good_ans_perc(a) = length(find(data_sort(ids, 2) == answer_comp)) ...
* 100 / nb_trials_per_param;
end

% plot(speeds, right_left_ans_perc)
end % end function
149 changes: 149 additions & 0 deletions analysis/LauraPlot.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
function [fighandle p50] = LauraPlot (filename)
% function [fighandle p50] = LauraPlot (filename)
%
% Plot the psychometric function for the intensity experiment
%
% Input Arguments
%
% ** filename [string]
% filename of the .dat file required for the analysis. In order to get
% everything working with this function the filename must follow this
% rule:
% * participant initials (2 letters),
% * condition (2 numbers),
% * session (2 letters).
%
% example: matthieu berjon, 55dB, session 1
% mb_55_s1.dat
% example: matthieu berjon, 40, pilot session
% mb_40_ps.dat
%
%
% Output arguments
%
% p50 [scalar]
% Point of subjective equality.
%
% fighandle [scalar]
% Handle to the figure
%
%
% More information
%
% The file contains on each line the following data
% test speed; standard intensity; direction; presentation; answer
%
% test speed: degree/sec
% standard intensity: decibels
% direction: 0 = left to right; 1 = right to left
% presentation: 0 = standard then test; 1 = test then standard
% answer: 0 = first goes faster; 1 = second goes faster
%
% We want to display on x (the speed) and on y (the test appears faster)
%
%
%
% KNOWN BUGS
%
% No known bugs
%
%
% TODO
%
% No todo
%
%
% modified: 08 Feb 2013
% author: matthieu berjon <matthieu.berjon@wavefield.fr>
% licence: BSD


% depending on the Operating system the path where are stored the data will be
% different
if IsOs('WIN')
pathname = 'D:\phd\data\intensity\orig';
else
pathname = '/home/mattberjon/phd/data/intensity/orig';
end

% we get information according to the name file
participant = filename(1:2);
intensity = filename(4:5);
session = filename(7:8);

% data loading
data = load ([pathname '/' filename]);

% store the data in a new variable
data_cur = data;

% speed and answers ID related to the current data format
SPD = 1;
RSP = 5;

% speeds and answers in new variables
speeds_cur = data_cur(:, SPD);
answers_cur = data_cur(:, RSP);

% extraction of the range of speeds used
speeds_u = unique (speeds_cur);

% some trials have the presentation inversed we need to inverse the answer in
% order to get all trials as standard then test presentation and inverse the
% related answers
pres_id = find (data_cur(:, 4) == 1);
answers_cur(pres_id) = ~answers_cur(pres_id);

% Now we compute the percentage of good answers for each test conditions
for a = 1:length (speeds_u)
% we look for trials corresponding to the given test value
id = find (speeds_cur == speeds_u(a));
% we sum the answers (because it only ones or zeros
r = sum (answers_cur(id));
% counting of the number of trials for that condition
n(a) = length (id);
% percentage of the given condition
pc(a) = r / n(a) * 100;
end

% Fitting of the points through a Probit analysis
[fit_signal prob_perc p50] = ProbitFit (speeds_u', pc, n);

% some parameters for plotting such as color, marker for the points and the
% size of the labels
color = [27 158 119] / 255;
marker = ['o'];
label_size = 18;
text_size = 14;
% to place some information correctly we need to convert some units in
% percentages
speeds_range = max (speeds_u) - min (speeds_u);
margin = 2 * speeds_range / 100;
% plot infos
infos = {['participant: ' participant]; ...
['session: ' session]; ...
['condition: ' intensity]; ...
['P50: ' num2str(p50)]};

% creation of new figure
fighandle = figure();
% points representing the percentages
plot (speeds_u, pc, marker, 'MarkerFaceColor', color, 'MarkerEdgeColor', color)
% hold on let us to draw several things on the same figure (otherwise it will
% erase what we drawn before and plot the new result
hold on
% psychometric fit
plot (fit_signal, prob_perc, 'Color', color, 'LineWidth', 2)
% line representing the p50 along the X axis
plot ([min(speeds_u) max(speeds_u)], [50 50], 'k', 'LineStyle', '-.')
% line representing the p50 along the Y axis
plot ([p50 p50], [0 50], 'Color', color, 'LineStyle', '--')
% information about the participant, session and p50
text ((min(speeds_u)+margin), 80, infos, 'FontSize', text_size)
% label on X
xlabel ('test speeds (deg/s)', 'FontSize', label_size)
% label on Y
axis ([min(speeds_u) max(speeds_u) 0 100])
ylabel ('test perceived as fastest (%)', 'FontSize', label_size)
set (gca, 'YTick', [0 50 100])
end

0 comments on commit ad8e50e

Please sign in to comment.