function CreateDesignMatrix() { var bvqx = Application.BrainVoyagerQX; doc = bvqx.ActiveDocument(); doc.ClearDesignMatrix(); doc.AddPredictor("LVF"); doc.SetPredictorValuesFromCondition("LVF", "Objects in LVF", 1.0); doc.ApplyHemodynamicResponseFunctionToPredictor("LVF"); doc.AddPredictor("RVF"); doc.SetPredictorValuesFromCondition("RVF", "Objects in RVF", 1.0); doc.ApplyHemodynamicResponseFunctionToPredictor("RVF"); doc.AddPredictor("BVF"); doc.SetPredictorValuesFromCondition("BVF", "Objects in BVF", 1.0); doc.ApplyHemodynamicResponseFunctionToPredictor("BVF"); // You can also set any value at any time point (interval), here we define a linear trend predictor doc.AddPredictor("Linear Trend"); for(i = 1; i<= doc.NrOfVolumes; i++) { value = 0.1*i; doc.SetPredictorValues("Linear Trend", i, i, value); } doc.ScalePredictorValues("Linear Trend", 1.0, false); doc.SaveSingleStudyGLMDesignMatrix("CG_OBJECTS_FROMSCRIPT.rtc"); doc.CorrectForSerialCorrelations = true; doc.ComputeSingleStudyGLM(); doc.ShowGLM(); doc.SaveGLM("CG_OBJECTS_FROMSCRIPT.glm"); doc.ClearDesignMatrix(); doc.LoadSingleStudyGLMDesignMatrix("CG_OBJECTS_FROMSCRIPT.rtc"); doc.ComputeSingleStudyGLM(); doc.ShowGLM(); } function OverlayContrasts() { var bvqx = Application.BrainVoyagerQX; doc = bvqx.ActiveDocument(); doc.LoadGLM("CG_OBJECTS_FROMSCRIPT.glm"); doc.ClearContrasts(); doc.AddContrast("LVF > RVF"); doc.SetContrastValue("LVF", +1); doc.SetContrastValue("RVF", -1); //alternatively: doc.SetContrastString("1 -1 0 0"); // or ("Index" starts with 1) //doc.SetContrastValueAtIndex(1, +1); //doc.SetContrastValueAtIndex(2, -1); doc.ShowGLM(); } function CreateMultiStudyDesignMatrix() { var bvqx = Application.BrainVoyagerQX; var path = "C:/BVQXSampleData/ClockTask/"; doc = bvqx.OpenDocument(path + "BS_TAL.vmr"); doc.ClearMultiStudyGLMDefinition(); doc.AddStudyAndDesignMatrix( path + "BS_run1_r1_pp.vtc", path + "ClockTaskDesignMatrix_run1.rtc"); doc.AddStudyAndDesignMatrix( path + "BS_run2_l1_pp.vtc", path + "ClockTaskDesignMatrix_run2.rtc"); doc.AddStudyAndDesignMatrix( path + "ML_run1_r1_pp.vtc", path + "ClockTaskDesignMatrix_run1.rtc"); doc.AddStudyAndDesignMatrix( path + "ML_run2_l2_pp.vtc", path + "ClockTaskDesignMatrix_run2.rtc"); doc.SeparationOfSubjectPredictors = true; doc.ZTransformStudies = true; doc.SaveMultiStudyGLMDefinitionFile("TWOSUBJECTS_FROMSCRIPT.mdm"); // Now compute the GLM doc.CorrectForSerialCorrelations = false; doc.ComputeMultiStudyGLM(); doc.ShowGLM(); doc.SaveGLM("TWOSUBJS_FROMSCRIPT.glm"); // Test also new RFX GLM doc.PSCTransformStudies = true; doc.ComputeRFXGLM(); doc.SaveGLM("RFXGLM_FROMSCRIPT.glm"); }