Skip to content

BSS-Research-Support/rwave-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Python API for rWave: remote wave generator for the neuroConn tDCS.

1. About

This repository contains the API to communicate with the rWave USB-device, developed by the Research Support group of the faculty of Behavioral and Social Science from the University of Groningen. rWave is an external wave generator to be used with the remote input of the neuroConn tDCS.

2. Dependencies

The rwave-api API uses HIDAPI, a cython module to communicate with HID-class USB devices.

3. Device Permission for Linux

Permission for using rWave (HID) device should be added to udev rules by adding the next line:

SUBSYSTEM=="usb", ATTRS{idVendor}=="cafe", ATTRS{idProduct}=="4004", GROUP="plugdev", MODE="0660"

The user should be a member of the plugdev -group.

Check with:

$ groups username

If this is not the case, add the user to the plugdev group by typing:

$ sudo usermod -a -G plugdev username

4. RemoteWave API Summary

The RemoteWave class provides a Python interface for controlling the rWave device via USB HID. Public methods are organized into frequency, phase, amplitude, and control APIs.

4.1 Frequency Control

write_freq_theta(frequency: float) -> None
Set the frequency of the theta wave in Hz.

Range: FREQ_MIN ≤ frequency ≤ FREQ_MAX.

write_freq_gamma1(frequency: float) -> None
Set the frequency of the gamma1 wave in Hz.

Range: FREQ_MIN ≤ frequency ≤ FREQ_MAX.

write_freq_gamma2(frequency: float) -> None
Set the frequency of the gamma2 wave in Hz.

Range: FREQ_MIN ≤ frequency ≤ FREQ_MAX.

4.2 Phase Control

write_phase_theta(phase_angle: float) -> None
Set the phase angle of the theta wave in degrees.

Range: PHASE_MIN ≤ phase_angle ≤ PHASE_MAX.

write_phase_gamma1(phase_angle: float) -> None
Set the phase angle of the gamma1 wave in degrees.

Range: PHASE_MIN ≤ phase_angle ≤ PHASE_MAX.

write_phase_gamma2(phase_angle: float) -> None
Set the phase angle of the gamma2 wave in degrees.

Range: PHASE_MIN ≤ phase_angle ≤ PHASE_MAX.

write_start_phase_gamma1(phase_angle: float) -> None
Set the start phase of gamma1 relative to theta, in degrees.

write_start_phase_gamma2(phase_angle: float) -> None
Set the start phase of gamma2 relative to theta, in degrees.

write_trigger_phase(phase_angle: float) -> None
Set the phase of the trigger output pulse relative to the theta wave, in degrees.

4.3 Amplitude Control

(if you expose them — otherwise these remain internal)

write_ampl_theta(amplitude: int) -> None
Set amplitude for the theta wave.

Range: AMPL_MIN ≤ amplitude ≤ AMPL_MAX.

write_ampl_gamma1(amplitude: int) -> None
Set amplitude for the gamma1 wave.

write_ampl_gamma2(amplitude: int) -> None
Set amplitude for the gamma2 wave.

4.4 Device & Output Control

open_device() -> None
Open connection to the rWave device.

close_device() -> None
Close connection to the device.

wave_start() -> None
Start waveform generation.

wave_stop() -> None
Stop waveform generation.

send_params() -> None
Send the current parameter buffer (hid_out_pkg) to the device.

5. Python coding examples

from rwave_api import RemoteWave

mywave = RemoteWave()
#print(mywave.scan())

mywave.attach()

input("Press Enter to continue...")

try:
    mywave.write_freq_theta(3.0)
except ValueError as e:
    logging.error("Invalid parameter: %s", e)

mywave.start()

mywave.close()

6.0 rWave Master GUI

The rWave Master control panel:

rWM_GUI.png

Usage:

    1. Connect the rWave device to the PC.
    1. First open the Select Device dropdown menu, select rWave and press Connect.
    1. Change settings and press Wave update/start to start generating the wave.

Description of the input fields: (to be continued...)

7. License

The rWave-api API is distributed under the terms of the GNU General Public License 3. The full license should be included in the file COPYING, or can be obtained from

http://www.gnu.org/licenses/gpl.txt

About

Python API and GUI for the rWave device.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages