-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUtils.py
More file actions
26 lines (18 loc) · 785 Bytes
/
Utils.py
File metadata and controls
26 lines (18 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 02 18:16:20 2015
@author: Andrew
"""
import numpy
import math
def binary_to_digital_map(bin_buffer):
# If we have a sequence of 1s and 0s corresponding to digital ON and OFF times,
# we want to map this to digital commands that
# the digital ports can read and implement.
# Input should be mapped as a 2d numpy array (dtype=numpy.uint32), rows are individual lines, columns
# are continuous time points. Ignores sampling rate until we tell NIDAQmx what it is.
digital = numpy.zeros((bin_buffer.shape[0], bin_buffer.shape[1]))
n_lines = digital.shape[0]
for line in range(n_lines):
digital[line] = bin_buffer[line] * math.pow(2, line)
return numpy.uint32(digital)