Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/deploy_cpp_libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ jobs:
cmake-version: '3.21.x'
- name: Install Ninja
if: (matrix.os == 'macos-14')
uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.10.2
run: |
if ! command -v ninja; then
brew install ninja
fi
ninja --version
# build simpleble outside from brainflow because of different deployment targets
- name: Compile SimpleBLE MacOS
if: (matrix.os == 'macos-14')
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/run_unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ jobs:
npm install -g ts-node
- name: Install Ninja
if: (matrix.os == 'macos-14')
uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.10.2
run: |
if ! command -v ninja; then
brew install ninja
fi
ninja --version
- name: Install Julia
uses: julia-actions/setup-julia@v2
with:
Expand Down
12 changes: 12 additions & 0 deletions cpp_package/src/board_shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,18 @@ std::vector<int> BoardShim::get_ppg_channels (int board_id, int preset)
return std::vector<int> (channels, channels + len);
}

std::vector<int> BoardShim::get_optical_channels (int board_id, int preset)
{
int channels[MAX_CHANNELS];
int len = 0;
int res = ::get_optical_channels (board_id, preset, channels, &len);
if (res != (int)BrainFlowExitCodes::STATUS_OK)
{
throw BrainFlowException ("failed to get board info", res);
}
return std::vector<int> (channels, channels + len);
}

std::vector<int> BoardShim::get_accel_channels (int board_id, int preset)
{
int channels[MAX_CHANNELS];
Expand Down
7 changes: 7 additions & 0 deletions cpp_package/src/inc/board_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ class BoardShim
*/
static std::vector<int> get_ppg_channels (
int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET);
/**
* get row indices which hold optical data
* @param board_id board id of your device
* @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
*/
static std::vector<int> get_optical_channels (
int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET);
/**
* get row indices which hold EDA data
* @param board_id board id of your device
Expand Down
20 changes: 19 additions & 1 deletion csharp_package/brainflow/brainflow/board_controller_library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ public enum BoardIds
OB3000_24_CHANNELS_BOARD = 63,
BIOLISTENER_BOARD = 64,
IRONBCI_32_BOARD = 65,
NEUROPAWN_KNIGHT_BOARD_IMU = 66
NEUROPAWN_KNIGHT_BOARD_IMU = 66,
MUSE_S_ANTHENA_BOARD = 67
};


Expand Down Expand Up @@ -183,6 +184,8 @@ public static class BoardControllerLibrary64
[DllImport ("BoardController", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_ppg_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_optical_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_accel_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_rotation_channels (int board_id, int preset, int[] channels, int[] len);
Expand Down Expand Up @@ -275,6 +278,8 @@ public static class BoardControllerLibrary32
[DllImport ("BoardController32", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_ppg_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController32", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_optical_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController32", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_accel_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController32", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_rotation_channels (int board_id, int preset, int[] channels, int[] len);
Expand Down Expand Up @@ -773,6 +778,19 @@ public static int get_ppg_channels (int board_id, int preset, int[] channels, in
return (int)BrainFlowExitCodes.GENERAL_ERROR;
}

public static int get_optical_channels (int board_id, int preset, int[] channels, int[] len)
{
switch (PlatformHelper.get_library_environment ())
{
case LibraryEnvironment.x64:
return BoardControllerLibrary64.get_optical_channels (board_id, preset, channels, len);
case LibraryEnvironment.x86:
return BoardControllerLibrary32.get_optical_channels (board_id, preset, channels, len);
}

return (int)BrainFlowExitCodes.GENERAL_ERROR;
}

public static int get_accel_channels (int board_id, int preset, int[] channels, int[] len)
{
switch (PlatformHelper.get_library_environment ())
Expand Down
3 changes: 3 additions & 0 deletions csharp_package/brainflow/brainflow/board_descr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class BoardDescr
[DataMember]
public int[] ppg_channels;
[DataMember]
public int[] optical_channels;
[DataMember]
public int[] eda_channels;
[DataMember]
public int[] accel_channels;
Expand Down Expand Up @@ -54,6 +56,7 @@ public BoardDescr ()
exg_channels = null;
emg_channels = null;
ppg_channels = null;
optical_channels = null;
eda_channels = null;
accel_channels = null;
rotation_channels = null;
Expand Down
24 changes: 24 additions & 0 deletions csharp_package/brainflow/brainflow/board_shim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,30 @@ public static int[] get_ppg_channels (int board_id, int preset = (int)BrainFlowP
return result;
}

/// <summary>
/// get row indices which hold optical data
/// </summary>
/// <param name="board_id"></param>
/// <param name="preset">preset for device</param>
/// <returns>array of row nums</returns>
/// <exception cref="BrainFlowException">If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR</exception>
public static int[] get_optical_channels (int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)
{
int[] len = new int[1];
int[] channels = new int[512];
int res = BoardControllerLibrary.get_optical_channels (board_id, preset, channels, len);
if (res != (int)BrainFlowExitCodes.STATUS_OK)
{
throw new BrainFlowError (res);
}
int[] result = new int[len[0]];
for (int i = 0; i < len[0]; i++)
{
result[i] = channels[i];
}
return result;
}

/// <summary>
/// get row indices which hold accel data
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions docs/SupportedBoards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ Initialization Example:
params = BrainFlowInputParams()
params.serial_port = "COM3"
params.other_info = '{"gain": 6}' # optional: set gain to allowed values: 1, 2, 3, 4, 6, 8, 12 (default)

board = BoardShim(BoardIds.NEUROPAWN_KNIGHT_BOARD, params)

**On Unix-like systems you may need to configure permissions for serial port or run with sudo.**
Expand Down Expand Up @@ -1470,7 +1470,7 @@ Initialization Example:
params = BrainFlowInputParams()
params.serial_port = "COM3"
params.other_info = '{"gain": 6}' # optional: set gain to allowed values: 1, 2, 3, 4, 6, 8, 12 (default)

board = BoardShim(BoardIds.NEUROPAWN_KNIGHT_BOARD_IMU, params)

**On Unix-like systems you may need to configure permissions for serial port or run with sudo.**
Expand Down Expand Up @@ -1560,4 +1560,4 @@ Supported platforms:
- Windows
- Linux
- MacOS
- Devices like Raspberry Pi
- Devices like Raspberry Pi
4 changes: 2 additions & 2 deletions emulator/brainflow_emulator/galea_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self):
self.channel_on_off = [1] * 24
self.channel_identifiers = [
'1', '2', '3', '4', '5', '6', '7', '8',
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
'A', 'S', 'D', 'G', 'H', 'J', 'K', 'L'
]

Expand Down Expand Up @@ -147,4 +147,4 @@ def main():

if __name__ == '__main__':
logging.basicConfig(format='%(asctime)s %(levelname)-8s %(message)s', level=logging.INFO)
main()
main()
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class BoardDescr
public List<Integer> exg_channels;
public List<Integer> emg_channels;
public List<Integer> ppg_channels;
public List<Integer> optical_channels;
public List<Integer> eda_channels;
public List<Integer> accel_channels;
public List<Integer> rotation_channels;
Expand All @@ -33,6 +34,7 @@ public BoardDescr ()
exg_channels = null;
emg_channels = null;
ppg_channels = null;
optical_channels = null;
eda_channels = null;
accel_channels = null;
rotation_channels = null;
Expand Down
3 changes: 2 additions & 1 deletion java_package/brainflow/src/main/java/brainflow/BoardIds.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public enum BoardIds
OB3000_24_CHANNELS_BOARD(63),
BIOLISTENER_BOARD(64),
IRONBCI_32_BOARD(65),
NEUROPAWN_KNIGHT_BOARD_IMU(66);
NEUROPAWN_KNIGHT_BOARD_IMU(66),
MUSE_S_ANTHENA_BOARD(67);

private final int board_id;
private static final Map<Integer, BoardIds> bi_map = new HashMap<Integer, BoardIds> ();
Expand Down
46 changes: 46 additions & 0 deletions java_package/brainflow/src/main/java/brainflow/BoardShim.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ int get_current_board_data (int num_samples, int preset, double[] data_buf, int[

int get_ppg_channels (int board_id, int preset, int[] ppg_channels, int[] len);

int get_optical_channels (int board_id, int preset, int[] optical_channels, int[] len);

int get_accel_channels (int board_id, int preset, int[] accel_channels, int[] len);

int get_rotation_channels (int board_id, int preset, int[] rotation_channels, int[] len);
Expand Down Expand Up @@ -1108,6 +1110,50 @@ public static int[] get_ppg_channels (BoardIds board_id) throws BrainFlowError
return get_ppg_channels (board_id.get_code ());
}

/**
* get row indices in returned by get_board_data() 2d array which contain
* optical data
*/
public static int[] get_optical_channels (int board_id, BrainFlowPresets preset) throws BrainFlowError
{
int[] len = new int[1];
int[] channels = new int[512];
int ec = instance.get_optical_channels (board_id, preset.get_code (), channels, len);
if (ec != BrainFlowExitCode.STATUS_OK.get_code ())
{
throw new BrainFlowError ("Error in board info getter", ec);
}

return Arrays.copyOfRange (channels, 0, len[0]);
}

/**
* get row indices in returned by get_board_data() 2d array which contain
* optical data
*/
public static int[] get_optical_channels (int board_id) throws BrainFlowError
{
return get_optical_channels (board_id, BrainFlowPresets.DEFAULT_PRESET);
}

/**
* get row indices in returned by get_board_data() 2d array which contain
* optical data
*/
public static int[] get_optical_channels (BoardIds board_id, BrainFlowPresets preset) throws BrainFlowError
{
return get_optical_channels (board_id.get_code (), preset);
}

/**
* get row indices in returned by get_board_data() 2d array which contain
* optical data
*/
public static int[] get_optical_channels (BoardIds board_id) throws BrainFlowError
{
return get_optical_channels (board_id.get_code ());
}

/**
* get row indices in returned by get_board_data() 2d array which contain accel
* data
Expand Down
2 changes: 2 additions & 0 deletions julia_package/brainflow/src/board_shim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export BrainFlowInputParams
BIOLISTENER_BOARD = 64
IRONBCI_32_BOARD = 65
NEUROPAWN_KNIGHT_BOARD_IMU = 66
MUSE_S_ANTHENA_BOARD = 67

end

Expand Down Expand Up @@ -201,6 +202,7 @@ channel_function_names = (
:get_eog_channels,
:get_eda_channels,
:get_ppg_channels,
:get_optical_channels,
:get_accel_channels,
:get_rotation_channels,
:get_analog_channels,
Expand Down
3 changes: 2 additions & 1 deletion matlab_package/brainflow/BoardIds.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
BIOLISTENER_BOARD(64)
IRONBCI_32_BOARD(65)
NEUROPAWN_KNIGHT_BOARD_IMU(66)
MUSE_S_ANTHENA_BOARD(67)
end
end
end
11 changes: 11 additions & 0 deletions matlab_package/brainflow/BoardShim.m
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,17 @@ function log_message(log_level, message)
ppg_channels = data.Value(1,1:num_channels.Value) + 1;
end

function optical_channels = get_optical_channels(board_id, preset)
% get optical channels for provided board id
task_name = 'get_optical_channels';
num_channels = libpointer('int32Ptr', 0);
data = libpointer('int32Ptr', zeros(1, 512));
lib_name = BoardShim.load_lib();
exit_code = calllib(lib_name, task_name, board_id, preset, data, num_channels);
BoardShim.check_ec(exit_code, task_name);
optical_channels = data.Value(1,1:num_channels.Value) + 1;
end

function eda_channels = get_eda_channels(board_id, preset)
% get eda channels for provided board id
task_name = 'get_eda_channels';
Expand Down
16 changes: 16 additions & 0 deletions nodejs_package/brainflow/board_shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class BoardControllerDLL extends BoardControllerFunctions
this.getEogChannels = this.lib.func(CLike.get_eog_channels);
this.getEcgChannels = this.lib.func(CLike.get_ecg_channels);
this.getPpgChannels = this.lib.func(CLike.get_ppg_channels);
this.getOpticalChannels = this.lib.func(CLike.get_optical_channels);
this.getEdaChannels = this.lib.func(CLike.get_eda_channels);
this.getAccelChannels = this.lib.func(CLike.get_accel_channels);
this.getRotationChannels = this.lib.func(CLike.get_rotation_channels);
Expand Down Expand Up @@ -546,6 +547,21 @@ export class BoardShim
return сhannels.slice(0, numChannels[0]);
}

public static getOpticalChannels(
boardId: BoardIds, preset = BrainFlowPresets.DEFAULT_PRESET): number[]
{
const numChannels = [0];
const сhannels = [...new Array (512).fill(0)];
const res =
BoardControllerDLL.getInstance().getOpticalChannels(
boardId, preset, сhannels, numChannels);
if (res !== BrainFlowExitCodes.STATUS_OK)
{
throw new BrainFlowError (res, 'Could not get board info');
}
return сhannels.slice(0, numChannels[0]);
}

public static getEdaChannels(
boardId: BoardIds, preset = BrainFlowPresets.DEFAULT_PRESET): number[]
{
Expand Down
4 changes: 3 additions & 1 deletion nodejs_package/brainflow/brainflow.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export enum BoardIds {
SYNCHRONI_UNO_1_CHANNELS_BOARD = 62,
OB3000_24_CHANNELS_BOARD = 63,
BIOLISTENER_BOARD = 64,
IRONBCI_32_BOARD = 65
IRONBCI_32_BOARD = 65,
NEUROPAWN_KNIGHT_BOARD_IMU = 66,
MUSE_S_ANTHENA_BOARD = 67
}

export enum IpProtocolTypes {
Expand Down
8 changes: 8 additions & 0 deletions nodejs_package/brainflow/functions.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export enum BoardControllerCLikeFunctions {
'int get_eog_channels (int board_id, int preset, _Inout_ int *channels, _Inout_ int *len)',
get_ppg_channels =
'int get_ppg_channels (int board_id, int preset, _Inout_ int *channels, _Inout_ int *len)',
get_optical_channels =
'int get_optical_channels (int board_id, int preset, _Inout_ int *channels, _Inout_ int *len)',
get_eda_channels =
'int get_eda_channels (int board_id, int preset, _Inout_ int *channels, _Inout_ int *len)',
get_accel_channels =
Expand Down Expand Up @@ -226,6 +228,12 @@ export class BoardControllerFunctions
ppgChannels: number[],
len: number[],
) => BrainFlowExitCodes;
getOpticalChannels!: (
boardId: BoardIds,
preset: BrainFlowPresets,
opticalChannels: number[],
len: number[],
) => BrainFlowExitCodes;
getEdaChannels!: (
boardId: BoardIds,
preset: BrainFlowPresets,
Expand Down
Loading
Loading