john-judge / PhotoLib

Builds a camera/electrode management DLL to expose to Python applications
1 stars 0 forks source link

July - August 2021: NI-DAQmx integration and PyPhoto21 GUI #1

Closed john-judge closed 3 years ago

john-judge commented 3 years ago

Continuation of @https://github.com/john-judge/PhotoZ_upgrades/issues/21

7/26/21

Resolved errors by keeping sampling rate non-zero and finite, and resolving a name conflict for the DO buffer outputs Next: plot the fp_data we are getting back and see if it's reasonable.

john-judge commented 3 years ago

7/27/21

1)

2)

pyPhoto_w_FP

john-judge commented 3 years ago

7/29/21

Frame and Trace viewers connected. Next: stimulation settings, and use this to test whether NI-DAQmx is working properly

11:05 AM

Finished connected GUI for TTL Output config to hardware module. This should pass the num_bursts, etc data on to the C++ Lib, which will use that in fillPDout to populate the DO data. We should see a change in the analog input FP data as we vary these settings. That'll be evidence of whether NI-DAQmx is set up properly.

john-judge commented 3 years ago

8/3/21

Successfully enabled NI-DAQmx: stimulation administered with configurable number of pulses and pulse-interval, and properly read back in via analog input.

john-judge commented 3 years ago

8/4/21

Reply from Chun regarding sync'ing Little Dave via NI clock:

For BNC ratio = 1, we set the camera to trigger mode (@ TXC 1) and make DO0 (black cable, resting high, low to trigger) to go low (to zero) to trigger the camera. Blue cable has the camera’s clock, which triggers the NI input.

For BNC ratio > 1, again @ TXC 1, but we use NI clock (the output and input is supposed to be synched), and DO0 (50% duty cycle per camera frame) to trigger camera (low to trigger), and NI input uses the same clock, but you can go at multiple frame rate of the camera’s.

DO0 should be "Dev1/port0/line0"

From TurboSM:

    if (NI_flag == 1) {
        resting_v = 1;
        trigger_v = 0;
    }
    else {
        resting_v = 0;
        trigger_v = 1;
    }

    for (i = 0; i < delay; ++i)
        output_data[i] = resting_v + 2;

The "+2" is done because line1 is the LED shutter -- SM uses DIgital Write U32 instead of Write Lines.

if (BNC_ratio > 1) {
        int m;
        for (; i < output_sample / BNC_ratio; ++i) {
            for (m = 0; m < BNC_ratio / 2; m++)
                output_data[i*BNC_ratio + m] = trigger_v + 2;
            for (; m < BNC_ratio; m++)
                output_data[i*BNC_ratio + m] = resting_v + 2;
        }
        for (m = (output_sample / BNC_ratio)*BNC_ratio; m < output_sample; m++)
            output_data[m] = trigger_v + 2;
        output_data[output_sample - 1] = trigger_v + 2;
    }
    else {
        for (; i < output_sample; ++i)
            output_data[i] = trigger_v + 2;
    }
john-judge commented 3 years ago

8/5/21

Talked to Meyer:

john-judge commented 3 years ago

8/6/21

8/7 - 8/8

8/9/21

image

8/10/21

To-do:

Syncing threads during Live Feed

Mainly we want to avoid the overhead of starting/closing true parallelism -- 2.08 s for single image is high. Evidence that reassembly takes only < 0.5 % of time spent in DLL code during live feed (current state, which is too slow)

Strategy

Use two sync flags (a numpy bool array) that is shared between the plotter Python thread and the acquisition thread that calls into the C++ DLL. This establishes a producer-consumer relationship:

john-judge commented 3 years ago

8/11/21 - 8/12/21

8/13/21