Skip to content

Commit 7703a28

Browse files
Merge pull request #63 from lab-neuro-comp/Deploy_Config
Deploy config
2 parents 223b682 + 416e491 commit 7703a28

14 files changed

+319
-218
lines changed

CONTRIBUTING.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
# How to contribute
3+
4+
This project is development as result of a university program for Neuroscience and Behaviour Laboratory in Biology Department of Universidade de Brasília (UnB),
5+
students are responsible for this code, but is built so that anyone willing to contribute can modify and help with development using github. In this file, that are some instructions and suggestions upon how to make your contribution, please read it before sending your changes.
6+
7+
8+
# Prerequisites
9+
10+
* Microsoft Visual Studio 2015+
11+
* [ResXManager](https://marketplace.visualstudio.com/items?itemName=TomEnglert.ResXManager) extension for VS
12+
13+
14+
15+
# Getting Started
16+
17+
To have access to our project you just have to clone this repository and open the .sln file (Microsoft Visual Studio Solution).
18+
19+
# Globalization
20+
21+
This program is currently available on:
22+
* English
23+
* Portuguese
24+
25+
Releases are made with separate versions of each language.
26+
There are texts needing translation to spanish [here](https://drive.google.com/open?id=174o9u04dX0g0KubeW1F5CiOCXC9EoPJ1hs0i8ae4fMU) so that it can also be available in spanish.
27+
28+
Localization is made by the use of resx files, managed on [ResXManager](https://marketplace.visualstudio.com/items?itemName=TomEnglert.ResXManager) a VS extension.
29+
Winform forms and usercontrols can be localizated only when their property "Localizable" is set true. Which of these files have a .resx for available languages that is used for static elements.
30+
31+
For dynamic elements, such as error messages displayed during run time, that are global resources located in:
32+
33+
![Localization Resources](https://raw.githubusercontent.com/wiki/lab-neuro-comp/Test-Platform/images/localization_resources.png)
34+
35+
To use resources in global files
36+
37+
38+
```
39+
// properties used to localize strings during runtime
40+
private ResourceManager LocRM = new ResourceManager("TestPlatform.Resources.Localizations.LocalizedResources", typeof(FormMain).Assembly);
41+
private CultureInfo currentCulture = CultureInfo.CurrentUICulture;
42+
43+
// getting string "reactionTest" from resources in current culture
44+
LocRM.GetString("reactionTest", currentCulture)
45+
```
46+
47+
48+
# Data structure
49+
50+
There is no database in this application, instead files are used. Below there is an image of the directory tree created for the program.
51+
52+
![Data structure](https://raw.githubusercontent.com/wiki/lab-neuro-comp/Test-Platform/images/data_structure.png)
53+
54+
55+
# Testing
56+
57+
Unit tests are kept in their own project inside solution. Until now, that are only tests for model classes.
58+
59+
![Tests project](https://raw.githubusercontent.com/wiki/lab-neuro-comp/Test-Platform/images/test_project.png)
60+
61+
You can run tests using visual studio default configurations.
62+
63+
![Running tests](https://raw.githubusercontent.com/wiki/lab-neuro-comp/Test-Platform/images/run_tests.png)
64+
65+
# Submitting changes
66+
67+
Please send a [GitHub Pull Request to TestPlatform](https://github.com/lab-neuro-comp/Test-Platform/pull/new/master) stating what you've done.
68+
The Pull Request will only be accepted if the contribution works in all cultures (en-US and pt-BR).

README.md

+32-16
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,46 @@
1-
# TestPlatform
1+
2+
# TestPlatform
23
[![Build status](https://ci.appveyor.com/api/projects/status/ldpimyp67n2c14mh?svg=true)](https://ci.appveyor.com/project/fabiolamfleury/test-platform)
4+
![Available for Windows](https://img.shields.io/badge/Available%20for-Windows-blue.svg)
5+
![Open source](https://camo.githubusercontent.com/d9ce827af4ec2b7b3c52ce4595bbb354d8b21405/68747470733a2f2f6261646765732e66726170736f66742e636f6d2f6f732f76312f6f70656e2d736f757263652e7376673f763d313032)
36

4-
TestPlatform is a project developed inside University of Brasilia Behavioral and Neuroscience Laboratory. It continuous the work initialized by https://github.com/lab-neuro-comp/StroopTest, including now ReactionTest and Experiments, and soon it will include another set of cognitive tests. This is a desktop application built to be used on Windows systems.
7+
Create executive function tests for your research with plenty customization.
58

6-
## Getting Started
9+
TestPlatform is a platform used in scientific research in Neuroscience and Behaviour fields. project for various executive functions tests paradigms. It continuous the work initialized by [StroopTest](https://github.com/lab-neuro-comp/StroopTest), including now ReactionTest and Experiments, and soon it will include another set of cognitive tests. This is a desktop application built to be used on Windows systems.
710

8-
To contribute to our project you just have to clone this repository and open the .sln file (Microsoft Visual Studio Solution).
11+
## Key features
912

10-
### Prerequisites
13+
* Create customized Stroop Test
14+
* Create customized Reaction Time Test
15+
* Create customized lists for your tests with images, words, colors and audios
16+
* Record audios
17+
* Record tests response from participant
18+
* Extensive results generated, that can be exported to .csv file
19+
* Create Experiment susing as many tests as needed of any paradigms in program
20+
21+
### Examples of executing tests
22+
23+
![Stroop Example Portuguese](https://raw.githubusercontent.com/wiki/lab-neuro-comp/Test-Platform/images/stroop_example_pt-BR.gif)
1124

25+
![Stroop Example English](https://raw.githubusercontent.com/wiki/lab-neuro-comp/Test-Platform/images/stroop_example_en-US.gif)
1226

27+
![Stroop Image Example](https://raw.githubusercontent.com/wiki/lab-neuro-comp/Test-Platform/images/stroop_example_image.gif)
1328

14-
```
15-
Microsoft Visual Studio 2015+
16-
TestDriven extension for VS
17-
```
29+
## Download
1830

31+
### Prerequisites
32+
33+
* .NET Framework 4.5.2 or greater
1934

20-
## Running the tests
35+
You can download latest installable version of TestPlatform for Windows [here](https://github.com/lab-neuro-comp/Test-Platform/releases/latest).
2136

22-
Unit tests are kept in their own project inside solution.
23-
![Testes unitários](https://raw.githubusercontent.com/wiki/lab-neuro-comp/StroopTest/img/unittest.png)
37+
## How to use it
2438

25-
You can run tests using visual studio default configurations.
26-
![Testes unitários](https://raw.githubusercontent.com/wiki/lab-neuro-comp/StroopTest/img/unittest2.png)
27-
Or you can rigth click on unit test project and select "Test with" and select NCover for coverage.
39+
After downloading the program you need to install it, just follow the installing wizard and a shortcut will be created in your Desktop area. And you are all set!
2840

41+
![Installing Program](https://raw.githubusercontent.com/wiki/lab-neuro-comp/Test-Platform/images/installing_program.png)
2942

30-
## Authors
43+
## Contributors
3144

3245
* **Hugo Honda Ferreira** - *Initial work with StroopTest* - [StroopTest](https://github.com/lab-neuro-comp/StroopTest)
3346

@@ -40,3 +53,6 @@ Or you can rigth click on unit test project and select "Test with" and select NC
4053

4154
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
4255

56+
## Contributing
57+
58+
Want to now more about the project and perhaps contribute to it? - check our [CONTRIBUTING.md](CONTRIBUTING.md) file for details

StroopTest/Models/Audio.cs

+73-8
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,45 @@
33
using System.Runtime.InteropServices;
44
using CSCore.Codecs.WAV;
55
using CSCore.SoundIn;
6+
using CSCore.CoreAudioAPI;
7+
using System;
8+
using System.Globalization;
9+
using System.Windows.Forms;
10+
using CSCore.Win32;
11+
using CSCore;
12+
using System.Collections.Generic;
13+
using System.Resources;
614

715
public class Audio
816
{
917
private WasapiCapture capture;
1018
private WaveWriter writer;
11-
19+
private const CaptureMode CaptureMode = Models.CaptureMode.Capture;
20+
21+
private ResourceManager LocRM = new ResourceManager("TestPlatform.Resources.Localizations.LocalizedResources", typeof(FormMain).Assembly);
22+
private CultureInfo currentCulture = CultureInfo.CurrentUICulture;
23+
1224
public bool StartRecording(string path)
1325
{
14-
this.capture = new WasapiCapture();
15-
this.capture.Initialize();
16-
this.writer = new WaveWriter(path, this.capture.WaveFormat);
17-
this.capture.DataAvailable += (s, e) =>
26+
if (isDeviceAvailable())
1827
{
28+
29+
30+
this.capture = new WasapiCapture();
31+
this.capture.Initialize();
32+
this.writer = new WaveWriter(path, this.capture.WaveFormat);
33+
this.capture.DataAvailable += (s, e) =>
34+
{
1935
// save the recorded audio
2036
this.writer.Write(e.Data, e.Offset, e.ByteCount);
21-
};
22-
this.capture.Start();
23-
return true;
37+
};
38+
this.capture.Start();
39+
return true;
40+
}
41+
else
42+
{
43+
throw new Exception(LocRM.GetString("audioDeviceNotAvailable",currentCulture));
44+
}
2445
}
2546

2647
public bool PauseRecording()
@@ -49,7 +70,51 @@ public void PlayAudio(string file)
4970
MciSendString("play " + file, null, 0, 0);
5071
}
5172

73+
private bool isDeviceAvailable()
74+
{
75+
List<object> deviceList = new List<object>();
76+
using (var deviceEnumerator = new MMDeviceEnumerator())
77+
using (var deviceCollection = deviceEnumerator.EnumAudioEndpoints(
78+
CaptureMode == CaptureMode.Capture ? DataFlow.Capture : DataFlow.Render, DeviceState.Active))
79+
{
80+
foreach (var device in deviceCollection)
81+
{
82+
var deviceFormat = WaveFormatFromBlob(device.PropertyStore[
83+
new PropertyKey(new Guid(0xf19f064d, 0x82c, 0x4e27, 0xbc, 0x73, 0x68, 0x82, 0xa1, 0xbb, 0x8e, 0x4c), 0)].BlobValue);
84+
85+
var item = new ListViewItem(device.FriendlyName) { Tag = device };
86+
item.SubItems.Add(deviceFormat.Channels.ToString(CultureInfo.InvariantCulture));
87+
88+
deviceList.Add(item);
89+
}
90+
}
91+
if (deviceList.Count > 0)
92+
{
93+
return true;
94+
}
95+
else
96+
{
97+
return false;
98+
}
99+
}
100+
101+
private static WaveFormat WaveFormatFromBlob(Blob blob)
102+
{
103+
if (blob.Length == 40)
104+
return (WaveFormat)Marshal.PtrToStructure(blob.Data, typeof(WaveFormatExtensible));
105+
return (WaveFormat)Marshal.PtrToStructure(blob.Data, typeof(WaveFormat));
106+
}
107+
108+
109+
52110
[DllImport("winmm.dll")]
53111
private static extern int MciSendString(string mciComando, string mciRetorno, int mciRetornoLeng, int callBack);
112+
113+
114+
}
115+
public enum CaptureMode
116+
{
117+
Capture,
118+
LoopbackCapture
54119
}
55120
}

StroopTest/Properties/AssemblyInfo.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Reflection;
1+
using System.Resources;
2+
using System.Reflection;
23
using System.Runtime.CompilerServices;
34
using System.Runtime.InteropServices;
45

@@ -10,7 +11,7 @@
1011
[assembly: AssemblyConfiguration("")]
1112
[assembly: AssemblyCompany("Laboratório de Neurociências e Comportamento")]
1213
[assembly: AssemblyProduct("TestPlatform")]
13-
[assembly: AssemblyCopyright("Copyright © Universidade de Brasília 2017")]
14+
[assembly: AssemblyCopyright("Copyright © Universidade de Brasília 2018")]
1415
[assembly: AssemblyTrademark("")]
1516
[assembly: AssemblyCulture("")]
1617
[assembly: InternalsVisibleTo("StroopUnitTestProject")]
@@ -32,5 +33,6 @@
3233
// You can specify all the values or you can default the Build and Revision Numbers
3334
// by using the '*' as shown below:
3435
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.*")]
36-
[assembly: AssemblyFileVersion("1.1.0.0")]
36+
[assembly: AssemblyVersion("2.0")]
37+
[assembly: AssemblyFileVersion("2.0")]
38+

StroopTest/README.txt

-54
This file was deleted.

StroopTest/Resources/Localizations/LocalizedResources.en-US.resx

+4-1
Original file line numberDiff line numberDiff line change
@@ -2208,8 +2208,11 @@ user to the stimulus or if there is no reaction to the stimulus(ms)&lt;/td&gt;
22082208
</data>
22092209
<data name="training" xml:space="preserve">
22102210
<value>Training</value>
2211-
</data>
2211+
</data>
22122212
<data name="removeProgramFromExperiment" xml:space="preserve">
22132213
<value>Wish to remove the program from the experiment?</value>
22142214
</data>
2215+
<data name="audioDeviceNotAvailable" xml:space="preserve">
2216+
<value>There are no devices available to record audio.</value>
2217+
</data>
22152218
</root>

StroopTest/Resources/Localizations/LocalizedResources.pt-BR.resx

+3
Original file line numberDiff line numberDiff line change
@@ -2203,4 +2203,7 @@ Mais informações: https://github.com/lab-neuro-comp/Test-Platform</value>
22032203
<data name="removeProgramFromExperiment" xml:space="preserve">
22042204
<value>Deseja remover o programa do experimento?</value>
22052205
</data>
2206+
<data name="audioDeviceNotAvailable" xml:space="preserve">
2207+
<value>Não existe nenhum dispositivo disponível para gravação de aúdio.</value>
2208+
</data>
22062209
</root>

0 commit comments

Comments
 (0)