Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tools/reprostim-timesync-stimuli for full automation #120

Open
yarikoptic opened this issue Nov 15, 2024 · 1 comment
Open

Refactor tools/reprostim-timesync-stimuli for full automation #120

yarikoptic opened this issue Nov 15, 2024 · 1 comment
Assignees

Comments

@yarikoptic
Copy link
Member

yarikoptic commented Nov 15, 2024

Part of the solution for

That script should have two loops:

  • loop awaiting for a video card to get connected, would not be showing anything
    • as soon as card connected -- get into the "sequence presentation mode" which
      • starts collecting samples into a new log file (based on prefix + datestamp) (ATM -- single file provided in CLI)
      • waits for trigger pulse (already has that)
      • upon arrival of trigger pulse starts loop
        • ATM loop is ntrials hardcoded to run 300 (IIRC) times and exits only when receives event q (from keyboard)
        • Needed: automatically quit the loop whenever MRI sequence ends (ie. "no more trigger pulses"). I think procedure should be
          • default to TR_timeout=4 (seconds) in the beginning. Use TR_timeout as time out for waiting for an event.
          • after receiving two first consecutive triggers pulses -- take the temporal distance between them +50% as the next value of TR_timeout
          • quit the loop whenever timing out of TR_timeout
      • close log file and get to the top of the loop to wait for the next MRI sequence.
      • when video card is disconnected -- quit the inner loop as likely would not be able to show anything since external display would be gone

May be that external loop should be coded completely separately into e.g. tools/reprostim-timesync-stimuli-cron and then drive the internal one (reprostim-timesync-stimuli) collecting samples for MRI sequences with already present/connected display.

@yarikoptic
Copy link
Member Author

yarikoptic commented Nov 27, 2024

Mermaid diagram for sequence of events:

sequenceDiagram
    Researcher->>+Magewell: Connect cable
    Researcher-->>+MRI: Gets ready for new run (new sequence e.g. func_task-finger_run-1)
    Researcher-->>+Magewell: Gets ready for new run (future: "displays start QR")
    MRI->>+Birch: Trigger pulse
    Birch->>+Researcher: Trigger pulse (5 via keyboard-like interface, USB) 
    MRI->>+Birch: Trigger pulse (after TR1)
    Birch->>+Researcher: Trigger pulse (5)
    Researcher-->>+Magewell: Starts the experimental stimuli protocol
    MRI->>+Birch: Trigger pulse (after 2*TR1)
    Birch->>+Researcher: Trigger pulse (5)
    MRI->>+Birch: Trigger pulse (after 3*TR1)
    Birch->>+Researcher: Trigger pulse (5)
    Researcher-->>+Magewell: Displays stimuli asking for response
    Participan->>+Birch: Response
    Birch->>+Researcher: Response (1)
    MRI->>+Birch: Trigger pulse (after 4*TR1)
    Birch->>+Researcher: Trigger pulse
    Researcher-->>+Magewell: Displays stimuli asking for response
    Participan->>+Birch: Response
    Birch->>+Researcher: Response (1) 
    Researcher-->>+Magewell: Ends the run (future: "displays end QR")
    Researcher-->>+MRI: Gets ready for new run (new sequence e.g. func_task-rest_run-2)
    Researcher-->>+Magewell: Gets ready for new run (future: "displays start QR")
    MRI->>+Birch: Trigger pulse
    Birch->>+Researcher: Trigger pulse (5) 
    MRI->>+Birch: Trigger pulse (after TR2)
    Birch->>+Researcher: Trigger pulse (5)
    MRI->>+Birch: Trigger pulse (after 2*TR2)
    Birch->>+Researcher: Trigger pulse (5)
    MRI->>+Birch: Trigger pulse (after 3*TR2)
    Birch->>+Researcher: Trigger pulse (5)
    MRI->>+Birch: Trigger pulse (after 4*TR2)
    Birch->>+Researcher: Trigger pulse (5)
    Researcher-->>+Magewell: Ends the run (future: "displays end QR")
    Researcher->>+Magewell: Disconnect cable
Loading

As discussed, potentially

  • could be a single log file/sequence across all runs for the same "attached video cable" and then we would "split them apart" outside.
  • it would be outside script which would monitor for VGA cable connect/disconnect and start/stop the sreprostim-timesync-stimuli script "gracefully" (so we do have all logs saved).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants