Skip to content

Commit c71ef5b

Browse files
committed
add support for biosemi datasets
1 parent 74015b6 commit c71ef5b

7 files changed

Lines changed: 73 additions & 146 deletions

File tree

README.md

Lines changed: 20 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,38 @@
1-
<!--
2-
3-
When you have set up your repo
4-
5-
**Unit tests and coverage**
6-
7-
[![](https://img.shields.io/badge/Octave-CI-blue?logo=Octave&logoColor=white)](https://github.com/Remi-gau/template_matlab_analysis/actions)
8-
![](https://github.com/Remi-gau/template_matlab_analysis/workflows/CI/badge.svg)
9-
10-
[![codecov](https://codecov.io/gh/Remi-gau/template_matlab_analysis/branch/master/graph/badge.svg)](https://codecov.io/gh/Remi-gau/template_matlab_analysis)
11-
12-
**Miss_hit linter**
13-
14-
[![Build Status](https://travis-ci.com/Remi-gau/template_matlab_analysis.svg?branch=master)](https://travis-ci.com/Remi-gau/template_matlab_analysis)
15-
16-
-->
17-
181
# Template repository for matlab analysis project
192

20-
## How to install and use this template
21-
22-
### Install with Git
23-
24-
1. Click the green button `Use this template`.
3+
## Requirements
254

26-
1. Give a name to the repository you want to create. Something short that
27-
contains the name of your experiment: `analysis_my_study`.
5+
- Matlab - version >2017? (Possibly compatible with older versions ; Not tested
6+
on Octave)
7+
- LetsWave - version 5 - 7
288

29-
1. Decide if you want this new repo to be public or private.
9+
- There is a bids-matlab "dependency" as a git sub-module that it will be
10+
installed automatically if you use the `--recursive` flag when you clone the
11+
repository (see the `install with git` section below).
3012

31-
1. Click on `Create repository from template`
32-
33-
You now have a copy of the template on your Github account. You can then
34-
download the code and the pre-set dependencies like this.
35-
36-
1. Click on green `Download` button and copy the `URL_to_your_repo` that is
37-
shown there.
13+
## Install with Git
3814

3915
1. Open a terminal and type this:
4016

4117
```bash
42-
git clone --recurse-submodules URL_to_your_repo
43-
```
44-
45-
This will set up everything automatically in your current directory.
46-
47-
## Content
48-
49-
```bash
50-
├── .git
51-
│ ├── COMMIT_EDITMSG
52-
│ ├── FETCH_HEAD
53-
│ ├── HEAD
54-
│ ├── ORIG_HEAD
55-
│ ├── branches
56-
│ ├── config
57-
│ ├── description
58-
│ ├── hooks
59-
│ │ ├── pre-commit.sample
60-
│ │ └── pre-push.sample
61-
│ ├── ...
62-
│ └── ...
63-
├── .github # where you put anything github related
64-
│ └── workflows # where you define your github actions
65-
│ └── moxunit.yml # a yaml file that defines a github action
66-
├── lib # where you put the code from external libraries (mathworks website or other github repositories)
67-
│ └── README.md
68-
├── src # WHERE YOU PUT YOUR CODE
69-
│ ├── README.md
70-
│ └── miss_hit.cfg
71-
├── docs # where you write your documentation using sphinx
72-
│ ├── make.bat
73-
│ ├── Makefile
74-
│ ├── README.md
75-
│ ├── requirements.txt # to set up the python environment for the doc
76-
│ └── source # the actual reStructured text file for your doc
77-
│ ├── conf.py
78-
│ ├── function_description.rst
79-
│ ├── index.rst
80-
│ ├── _static
81-
│ └── _templates
82-
├── tests # where you put your unit tests
83-
| ├── README.md
84-
| └── miss_hit.cfg
85-
├── .travis.yml # where you define the continuous integration done by Travis
86-
├── LICENSE
87-
├── README.md
88-
├── miss_hit.cfg # configuration file for the matlab miss hit linter
89-
└── initEnv.m # a .m file to set up your project (adds the right folder to the path)
90-
```
91-
92-
## Keeping your code stylish: miss hit linter
93-
94-
### Matlab code style guide and quality
95-
96-
We use the [MISS_HIT linter](https://github.com/florianschanda/miss_hit/) to
97-
automatically enforce / fix some code style issues and check for code quality.
98-
99-
The linter is a python package that can be installed with:
100-
101-
```bash
102-
pip3 install --user miss_hit
103-
```
104-
105-
The rules followed by MISS_HIT are in the
106-
[MISS_HIT configuration file](./miss_hit.cfg).
107-
108-
To check the code style of the whole repository, you can can simply type:
109-
110-
```bash
111-
mh_style .
112-
```
113-
114-
Some styling issues can be automatically fixed by using the `--fix` flag. You
115-
might need to rerun this command several times if there are a lot of issues.
116-
117-
```bash
118-
mh_style . --fix
18+
git clone --recurse-submodules https://github.com/cpp-lln-lab/letswave_bids_import.git
11919
```
12020

121-
Code quality can be checked with:
21+
## Usage
12222

123-
```bash
124-
mh_metric .
125-
```
23+
### Add it to the Matlab path.
12624

127-
To see only the issues that "break" the code quality rules set in the
128-
configuration file, type:
25+
You can do this by running the `init_env` that is in the root folder of the
26+
repository.
12927

130-
```bash
131-
mh_metric . --ci
13228
```
29+
this_dir = fileparts(mfilename('fullpath'));
13330
134-
The code style and quality is also checked during the
135-
[continuous integration](.github/workflows/miss_hit.yml).
136-
137-
For more information about MISS_HIT see its
138-
[documentation](https://florianschanda.github.io/miss_hit/).
139-
140-
## Python environment
141-
142-
More on this
143-
[here](https://the-turing-way.netlify.app/reproducible-research/renv/renv-package.html)
144-
145-
## Testing your code
31+
% input and output directory
32+
cfg.bidsroot = pwd;
33+
cfg.out_path = fullfile(cfg.bidsroot, 'derivatives');
14634
147-
The [MOxUnit testing framework](https://github.com/MOxUnit/MOxUnit) is set up to
148-
run tests automatically for any tests in the `tests` folder.
35+
initialize_letswave();
14936
150-
## Continuous integration
37+
import_bids(cfg);
38+
```

init_env.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function init_env()
1212
% MATLAB >= R2015b
1313
%
1414
% 2 - Add project to the O/M path
15+
%
1516
% (C) Copyright 2021 Remi Gau
1617

1718
octaveVersion = '4.0.3';

lib/bids-matlab

Submodule bids-matlab updated 525 files

src/importBids.m

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function import_bids(cfg)
1+
function importBids(cfg)
22
%
33
%
44
%
@@ -15,6 +15,8 @@ function import_bids(cfg)
1515

1616
cfg.filter = struct();
1717

18+
printCredits(cfg);
19+
1820
BIDS = bids.layout(cfg.bidsroot);
1921

2022
pipeline_name = 'letswave_bids_import';
@@ -51,12 +53,23 @@ function import_bids(cfg)
5153

5254
configuration.parameters.filenames = {files{iFile}};
5355

54-
[~, datasets] = LW_import_BDF('process', configuration);
56+
[~, datasets] = LW_import_SET('process', configuration);
5557

5658
save_data(files{iFile}, datasets);
5759

5860
delete(files{iFile});
5961

62+
case '.bdf'
63+
configuration = LW_import_BDF('default');
64+
65+
configuration.parameters.filenames = {files{iFile}};
66+
67+
[~, datasets] = LW_import_BDF('process', configuration);
68+
69+
save_data(files{iFile}, datasets);
70+
71+
delete(files{iFile});
72+
6073
otherwise
6174
% TODO
6275
warning('FORMAT NOT YET SUPPORTED');

src/utils/printCredits.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function repoURL = printCredits(cfg)
1+
function printCredits(cfg)
22
%
33
% TODO: use the .zenodo.json to load contributors
44
%

tests/test_importBids.m

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function test_suite = test_import_bids %#ok<*STOUT>
1+
function test_suite = test_importBids %#ok<*STOUT>
22
% (C) Copyright 2021 Remi Gau
33
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
44
test_functions = localfunctions(); %#ok<*NASGU>
@@ -7,24 +7,49 @@
77
initTestSuite;
88
end
99

10-
function test_import_bids_basic()
10+
function test_import_bids_eeglab()
1111

12-
clean_dir();
13-
14-
cfg.out_path = fullfile(this_dir(), 'output');
12+
cfg.out_path = fullfile(this_dir(), 'output', 'eeglab');
13+
14+
clean_dir(cfg.out_path);
1515

1616
cfg.bidsroot = fullfile(return_test_data_dir(), 'eeglab');
1717

1818
initialize_letswave();
1919
close all;
2020

21-
import_bids(cfg);
21+
importBids(cfg);
22+
23+
% TODO
24+
% add tests
25+
26+
% clean_dir();
27+
28+
end
29+
30+
function test_import_bids_biosemi()
31+
32+
cfg.out_path = fullfile(this_dir(), 'output', 'biosemi');
33+
34+
clean_dir(cfg.out_path);
35+
36+
cfg.bidsroot = fullfile(return_test_data_dir(), 'spm_multimodal');
37+
38+
initialize_letswave();
39+
close all;
40+
41+
importBids(cfg);
42+
43+
% TODO
44+
% add tests
45+
46+
% clean_dir();
2247

2348
end
2449

25-
function clean_dir()
26-
if exist(fullfile(this_dir(), 'output'), 'dir')
27-
rmdir(fullfile(this_dir(), 'output'), 's');
50+
function clean_dir(this_dir)
51+
if exist(this_dir, 'dir')
52+
rmdir(this_dir, 's');
2853
end
2954
end
3055

0 commit comments

Comments
 (0)