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.
The rwave-api API uses HIDAPI, a cython module to communicate with HID-class USB devices.
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
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.
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.
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.
(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.
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.
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()
The rWave Master control panel:
Usage:
-
- Connect the rWave device to the PC.
-
- First open the Select Device dropdown menu, select rWave and press Connect.
-
- Change settings and press Wave update/start to start generating the wave.
Description of the input fields: (to be continued...)
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
