LUKASZ D. KACZMAREK - PSYCHOPHYSIOLOGY LAB: POSITIVE GAMING & STREAMING
  • ABOUT
  • Publications
  • Resources
  • Blog

Moving data to Datapad in LabChart easily - helpful macro

11/29/2018

1 Comment

 
You can record a macro in LabChart for repeated parts of the data analysis. It is a great way to reduce your time for analyses. In fact, it is the only way to process physiological data without losing your mind if you have more than, say, 10 cases to analyze.

However... If you want to push the limit even further, you can use a simple subroutine that I wrote. Just copy the Sub DoBlock into your macro, and then used this command:

DoBlock "a", 20, "Forwards", 10

For the first parameter (here: a), enter the comment that you want to find.
For the second parameter (here: 20), enter how long selection you need.
For the third parameter, enter forwards (or just f), if you want the selection to be marked forward relative to the comment.
For the fourth parameter, enter how long chunks you want to transfer to data pad.

In the above example, LabChart will search for the comment "a," select 20 seconds after this comment, and transfer two blocks 10-sec long into Data Pada.

I found using such subroutine extremely useful to keep the macro clean when you need to process several parts of the signal.


Copy this to your macro:

Sub DoBlock(name, seconds, selectionDirection, chunks)

    'go to the beginning
    ' Begin Find
    ChannelIndex = 3
    SetAction = kSetPeriod
    SelectMode = kSelectAfter
    SelectTime = 0
    DataDisplayMode = kViewDataVisible
    SelectAll = True
    Direction = kSearchForward
    FindType = "Start of file"
    FindData = ""
    Call Doc.Find (ChannelIndex, SetAction, SelectMode, SelectTime, DataDisplayMode, SelectAll, Direction, FindType, FindData)
    ' End Find

    If selectionDirection = "forward"_
    OR selectionDirection = "forwards"_
    OR selectionDirection = "Forward"_
    OR selectionDirection = "Forwards"_
    OR selectionDirection = "f"_
    OR selectionDirection = "F" Then
        SelectMode = 0
    ElseIf selectionDirection = "backward"_
    OR selectionDirection = "backwards"_
    OR selectionDirection = "back"_
    OR selectionDirection = "Back"_
    OR selectionDirection = "Backward"_
    OR selectionDirection = "Backwards"_
    OR selectionDirection = "b"_
    OR selectionDirection = "B" Then
        SelectMode = 2
    ElseIf selectionDirection = "around"_
    OR selectionDirection = "Around"_
    OR selectionDirection = "a"_
    OR selectionDirection = "A" Then
        SelectMode = 1
    End if
    
    'select
    ' Begin Find
    ChannelIndex = 3
    SetAction = kSetPeriod
    'SelectMode = selectionDirection '
    SelectTime = seconds
    DataDisplayMode = kViewDataVisible
    SelectAll = True
    Direction = kSearchForward
    FindType = "Search for comment"
    FindData = "JustThisChannel=0;WhatToLookFor="+name+";"
    Call Doc.Find (ChannelIndex, SetAction, SelectMode, SelectTime, DataDisplayMode, SelectAll, Direction, FindType, FindData)
    ' End Find

    'add to datapad
    ' Begin MultipleAddToDataPad_Time
    TimeSecs = chunks
    EveryChecked = True
    EverySecs = chunks
    IntegralSelection = True
    SelectScope = kWithinSelection
    Call Doc.MultipleAddToDataPad_Time (TimeSecs, EveryChecked, EverySecs, IntegralSelection, SelectScope)
    ' End MultipleAddToDataPad_Time
End Sub



DISCLAIMER: Before you start processing your data with this macro, please make sure that it is doing what it is supposed to do with your data. You can compare the results with manual processing of a couple of files.
1 Comment
Deck Builders New Jersey link
3/23/2023 06:44:36 am

Hi, great reading your blog

Reply



Leave a Reply.

    Archives

    March 2022
    February 2022
    January 2022
    November 2019
    November 2018
    May 2018

    Categories

    All
    LabChart
    Macro
    Psychophysiology

    RSS Feed