+ All Categories
Home > Documents > Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of...

Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of...

Date post: 10-Jul-2020
Category:
Upload: others
View: 3 times
Download: 2 times
Share this document with a friend
58
Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk 1 , Sandon M. Griffin 1 , Roemer van der Meij 2 , Callum Dewar 1,3 , Ignacio Saez 1 , Jack J. Lin 4 , Giovanni Piantoni 5 , Jan-Mathijs Schoffelen 6 , Robert T. Knight 1,7 & Robert Oostenveld 6,8 1 Helen Wills Neuroscience Institute, University of California, Berkeley, Berkeley, CA 94720, USA; 2 Department of Cognitive Science, University of California, San Diego, La Jolla, CA 92093, USA; 3 College of Medicine, University of Illinois, Chicago, IL 60612, USA; 4 Department of Neurology, University of California, Irvine, Irvine, CA 92697, USA; 5 Massachusetts General Hospital and Harvard Medical School, Boston, MA 02114, USA; 6 Radboud University, Donders Institute for Brain, Cognition, and Behaviour, 6500 HB Nijmegen, The Netherlands; 7 Department of Psychology, University of California, Berkeley, Berkeley, CA 94720, USA; 8 NatMEG, Karolinska Institutet, SE-17177 Stockholm, Sweden Correspondence should be addressed to A.S. ([email protected]). Keywords: direct brain recording, electrocorticography, ECoG, stereoelectroencephalography, SEEG, epilepsy Abstract The exquisite spatiotemporal precision of human intracranial EEG recordings (iEEG) permits characterizing neural processing with a level of detail that is inaccessible to scalp-EEG, MEG, or fMRI. However, the same qualities that make iEEG an exceptionally powerful tool also present unique challenges. Until now, the fusion of anatomical data (MRI and CT images) with the electrophysiological data and its subsequent analysis has relied on technologically and conceptually challenging combinations of software. Here, we describe a comprehensive protocol that addresses the complexities associated with human iEEG, providing complete transparency and flexibility in the evolution of raw data into illustrative representations. The protocol is directly integrated with an open source toolbox for electrophysiological data analysis (FieldTrip). This allows iEEG researchers to build on a continuously growing body of scriptable and reproducible analysis methods that, over the past decade, have been developed and employed by a large research community. We demonstrate the protocol for an example complex iEEG data set to provide an intuitive and rapid approach to dealing with both neuroanatomical information and large electrophysiological data sets. We explain how the protocol can be largely automated, taking under an hour to complete, and readily adjusted to iEEG data sets with other characteristics. . CC-BY-NC 4.0 International license not certified by peer review) is the author/funder. It is made available under a The copyright holder for this preprint (which was this version posted December 8, 2017. . https://doi.org/10.1101/230912 doi: bioRxiv preprint
Transcript
Page 1: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Integratedanalysisofanatomicalandelectrophysiologicalhumanintracranialdata

ArjenStolk1,SandonM.Griffin1,RoemervanderMeij2,CallumDewar1,3,IgnacioSaez1,JackJ.Lin4,GiovanniPiantoni5,Jan-MathijsSchoffelen6,RobertT.Knight1,7&RobertOostenveld6,81HelenWillsNeuroscienceInstitute,UniversityofCalifornia,Berkeley,Berkeley,CA94720,USA;2DepartmentofCognitiveScience,UniversityofCalifornia,SanDiego,LaJolla,CA92093,USA;3CollegeofMedicine,UniversityofIllinois,Chicago,IL60612,USA;4DepartmentofNeurology,UniversityofCalifornia,Irvine,Irvine,CA92697,USA;5MassachusettsGeneralHospitalandHarvardMedicalSchool,Boston,MA02114,USA;6RadboudUniversity,DondersInstituteforBrain,Cognition,andBehaviour,6500HBNijmegen,TheNetherlands;7DepartmentofPsychology,UniversityofCalifornia,Berkeley,Berkeley,CA94720,USA;8NatMEG,KarolinskaInstitutet,SE-17177Stockholm,SwedenCorrespondenceshouldbeaddressedtoA.S.([email protected]).Keywords:directbrainrecording,electrocorticography,ECoG,stereoelectroencephalography,SEEG,epilepsyAbstractTheexquisitespatiotemporalprecisionofhumanintracranialEEGrecordings(iEEG)permitscharacterizingneuralprocessingwithalevelofdetailthatisinaccessibletoscalp-EEG,MEG,orfMRI.However,thesamequalitiesthatmakeiEEGanexceptionallypowerfultoolalsopresentuniquechallenges.Untilnow,thefusionofanatomicaldata(MRIandCTimages)withtheelectrophysiologicaldataanditssubsequentanalysishasreliedontechnologicallyandconceptuallychallengingcombinationsofsoftware.Here,wedescribeacomprehensiveprotocolthataddressesthecomplexitiesassociatedwithhumaniEEG,providingcompletetransparencyandflexibilityintheevolutionofrawdataintoillustrativerepresentations.Theprotocolisdirectlyintegratedwithanopensourcetoolboxforelectrophysiologicaldataanalysis(FieldTrip).ThisallowsiEEGresearcherstobuildonacontinuouslygrowingbodyofscriptableandreproducibleanalysismethodsthat,overthepastdecade,havebeendevelopedandemployedbyalargeresearchcommunity.WedemonstratetheprotocolforanexamplecomplexiEEGdatasettoprovideanintuitiveandrapidapproachtodealingwithbothneuroanatomicalinformationandlargeelectrophysiologicaldatasets.Weexplainhowtheprotocolcanbelargelyautomated,takingunderanhourtocomplete,andreadilyadjustedtoiEEGdatasetswithothercharacteristics.

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 2: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

INTRODUCTIONIntracranialEEG(iEEG)allowssimultaneousrecordingsfromtenstohundredsofelectrodesplaceddirectlyontheneocortex(electrocorticography,ECoG),orintracortically(stereoelectroencephalography,SEEG).Inhumans,themostcommonimplementationofiEEGiswhennon-invasivetechniquessuchasscalp-EEGandMRIdonotprovidesufficientinformationtoguidesurgeryinmedicationrefractoryepilepsypatients.Eachelectrodereflectstheactivityoftensofthousandsofneurons1,2,andtherecordingandstimulationoftheseneuralpopulationsallowforidentificationofepileptogeniczones,aswellasformappingoffunctionallyeloquentareasofhumancortextoguideneurosurgery.Theoutcomeoftheseprocedurescanbedirectlyobservedwhentheneuralorbehavioralresponseisstraightforwardsuchasspeecharrestormusclemovementwithdirectstimulation3.Anymorecomplexempiricalstudyrequiresaccurateknowledgeofanelectrode’slocationinrelationtothebrain’sanatomythatislinkedtothelocalelectrophysiologicalsignal.Thisintegratedinformationiskeytobasicandclinicalresearchworkaimedatunderstandinghumanneuralandcognitiveprocessing4,5. HumaniEEGanalysishastraditionallyreliedonstand-aloneandadhocworkflowsfortheseparateanalysisofanatomicalandfunctionalaspectsoftheiEEGdata,presentingresearcherswithaseriesofchallengestorealizethefullpotentialofthisexceptionallypowerfultool.Toprocesstheneuroanatomicaldataresearchlabsaretaskedwithassemblingsoftwarecombinationsfortheconversionoffileformats(e.g.,DICOMtoNIfTIusingMRIConvert),coregistrationofanatomicalscans(e.g.,CTtoMRIusingSPM6,FSL7,orAFNI8),localizationofelectrodes(e.g.,BioImageSuite9),andthesortingandlabelingofelectrodestomatchtheformatofthefunctionalrecordingfile(manually,orusingcustomsoftware).Thistechnologicalobstacleisreceivingincreasingattentionintheformofmoreefficientworkflowsforlocalizingandvisualizingelectrodes10–16,butnoprotocolexiststhatallowsresearcherstoefficientlyprocesstheanatomicaldatawithinasingleworkenvironment,andseamlesslyfusewiththeelectrophysiologicaldataanditssubsequentanalysis.Ideally,inthelightofscientificreproducibility17,suchaprotocolshouldalsoprovidecompletetransparencyintheevolutionofrawdataintoresultsandillustrativerepresentations,allowingforaconvenientandefficientexchangeofdataandworkflowsbetweenresearchers.Thesetwocomponentsareparticularlyvaluableinagrowingfieldwheretheanalysisofdataisuniquelycomplex,butwherethegoldstandardforthatanalysisisyettobedefined. Here,wedescribe–attheimplementationlevel–acomprehensiveprotocoltoaddresstheseriesofchallengesassociatedwithboththeanatomicalandfunctionalaspectsofhumaniEEGanalysis.TheprotocolisdirectlyintegratedwiththeMATLAB-basedopensourceFieldTriptoolbox(Box1),offeringtheopportunitytoreadilyandflexiblybuildonacontinuouslygrowingsetofanalysistechniquesthathavealreadybeendevelopedandemployedbyalargeresearchcommunity.TheFieldTriptoolboxsupportsthedataformatsofmostpopularelectrophysiologicaldataacquisitionsystemsandsharesanalysiscodewithothersoftwarepackagessuchasSPMandEEGLAB18.Incontrasttothehostofproprietaryprogramscurrentlyavailablefortheanalysisofelectrophysiologicaldata,thecentraltenetofFieldTripistoprovidecompletetransparencyinordertopromotea

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 3: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

deeperunderstandingoftheanalysistechniquesandenhancethequalityofthescientificworkthatdependsonthesetechniques.Accordingly,allcomputercodeisfullyaccessibleandthewell-defineddatastructurescontainfullprovenancetofacilitatesharingbetweenresearchers.OuraimistoutilizetheseopensourcefeaturestoadvancethefieldofhumaniEEGbypromotinginteractionwithinandacrossmethodologicallycontiguousresearchareas(e.g.,non-invasiveelectrophysiologysuchasEEGorMEG).ApplicationoftheprotocolOurprotocolisespeciallyusefulforstudyinghumanneuralandcognitiveprocesseswithintracranialEEG.HumaniEEGanalysisisuniquelycomplexbecauseitrequiresdealingwithbothneuroanatomicalandlargeelectrophysiologicaldatasets.ThescopeofiEEGencompassesawiderangeofbasicandclinicalresearch,varyingfromstudiesofhigher-ordercognition19,20tothelocalizationandunderstandingofthesourcesandfeaturesofepileptogenicactivity21,22.ThemethodologicalchallengesthatiEEGresearchersfacecanbegroupedintoobstaclesthatarecommontomostempiricalworkandobstaclesthatarestudy-specific.Thisprotocolaimstoresolvetheformer,whileprovidingadequatesupportandflexibilityforthelatter.AdvantagesandlimitationsoftheprotocolThemainadvantagesofourprotocolarethatit(i)guidestheresearcherfromthemultitudeofrawintracranialdatafilestointegratedobservations,inafastandefficientway,(ii)isdirectlyintegratedwithacomprehensiveandopensourcehubforelectrophysiologicaldataanalysis,(iii)canbereadilyadaptedandautomated,(iv)iscompletelytransparentand(v)producesreproducibleworkflowsanddatasetsthatcanbeeasilysharedandgeneralizedtootherresearchmodalities.ThemainlimitationisthattheMATLABcommandlineinterfacerequiressomebasicprogrammingknowledge,whichmayrequiremoreinitiallearningascomparedtotheexecutionofcomputercommandsthrougha(blackbox)graphicaluserinterface.However,theuseofcomputercommandscanberelativelyeasilymasteredbyvirtueofusingthisprotocol,pavingthewayforbatchscriptinginordertoefficientlydealwithrepeatedanalyseswithinandacrosssubjectsand,ultimately,foradeeperunderstandingoftheunderlyingalgorithms. Humanintracranialdatasetsareapproachedfromvariousanglesandcomeindifferentshapesandsizes,soitiscriticalforaprotocoltostriketherightbalancebetweenefficiencyandflexibility.Thisneedisfurtheramplifiedbytherelativelyuniquenatureofintracranialdata,typicallyimposinggreaterdemandsonalternativeoptionsandstrategiesintheanalysisthannon-invasivedatarecordedwithmorestandardizedhard-andsoftwareindedicatedlaboratorysettings.Besidesprovidingaquickguidetointerpretableresults,ourprotocolallowsforeasyswitchingbetweenmethodstoaccommodatedifferentcasesandsituations.Bychangingasingleparameteratexecution,onecanforinstancereadilyapplyadifferentfusioncostfunctionorfiltersetting.Utilizingthisversatilityshouldnotnegativelyimpactcontinuationwiththeprotocol.Infact,thefullandautomaticprovenance,incombinationwiththesystematicfilenaming,encouragesadaptingto

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 4: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

thecircumstancesbyalleviatingpotentialconcernsregardingoversightandreproducibility. ThespatiotemporalprecisionofintracranialEEGprovidesauniquewindowonneuralprocessing.Thesizeanddimensionsofthiswindow,however,maygrowdisproportionallylargewithcertaintypesofanalyses,complicatingtheoverallinterpretabilityofthedata.Startingfromthetwodimensionsoftherawneuralsignal(channelsandtime),atime-frequencyanalysis,forinstance,resultsin3dimensionsintheoutput(powerasfunctionofchannel,timeandfrequency),whereasbetween-channelconnectivityanalysisexpandsthecombinatorialspaceto4dimensions.Ourprotocoladdressesthisdimensionalityissueandillustrateshowtheinteractivemanipulationofanatomicallyinformedgraphicalrepresentationsoftheneuraldatafacilitatestheinspectionofthemulti-dimensionaloutcomeofaniEEGanalysis,takingmaximumadvantageofthegroundworklaidbytheintegratedprocessingoftheanatomicalandfunctionaldata.IntegrationwithFieldTripInadditiontothecompletetransparencythatcomeswithanopensourcetoolbox,theintegrationwithFieldTripprovidesuniquebenefitstoiEEGresearchersbyallowingthemtobuildonalgorithmsforreadinginrawdataofvariousformats,datapreprocessing,event-relatedpotentialanalysis,spectralanalysis,sourcemodeling,connectivityanalysis,classification,real-timedataprocessing,andstatisticalinference.AppliedtohumaniEEGdata,thesemethodspermitcharacterizationofneuralinformationflowwithalevelofdetailinaccessibletonon-invasivetechniques.Additionally,invasiveandnon-invasivehumanelectrophysiologycanbedirectlyoverlaidusingverysimilaranalysispipelinesforanintegrativeperspectiveofneuralprocessing,oracomparisonofMEG/EEGsourcereconstructionmethodswithiEEG. Theopensourcedevelopmentmodelallowsforarelativelyeasyextensionoftheprotocol.Forinstance,severaltechniquesexisttocompensateforelectrodedisplacementduetothe"brainshift"phenomenonexplainedbelow11,12,23–30.Givendifferentstrengthsandweaknesses,thesetechniquesmayneedtobeevaluatedonacase-by-casebasis.FieldTrip'smodulararchitecturefacilitatesdeveloperstoincorporatenewtechniquesanduserstosubsequentlyemploythosetechniquesbyvirtueofchangingasingleparameteratfunctioncall.Inasimilarvein,theprotocolcanbeextendedtoanumberofexcitingnewresearchareas.Theseincludesingle-andmultiunitrecordings,‘NeuroGrid’recordings31,wireless'NeuralDust'recordings32,(deep)brainstimulation33,34,andmultimodalimaging12.Supportedbyagrowingcommunityofdeveloperscommittedtotheongoingpushtoimprovedataanalysismethods,wewillcoordinatewiththesenewelectrophysiologicalendeavorsandcontinuesharinganalysiscodewithothersoftwarepackages.CompatibilitywithFreeSurferTheprotocoliscompatiblewiththefreelyavailablesoftwarepackageFreeSurfer35.Althoughoptional,processingoftheanatomicalMRIwithFreeSurfer(Step6)offersseveraladvantagesforsubsequentanalysisanddatainterpretation.ProcessingtheMRIwithFreeSurferresultsinthecreationofacorticalmesh,consistingof

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 5: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

approximatelyequallysizedtrianglesthatformatopologicalsphereforeachofthecerebralhemispheres.Thiscorticalmeshisparticularlyconvenientforananatomicallyrealisticrepresentationoftheelectrophysiologicaldataontheneocortex(e.g.,bottomcenterinFig.1).Asmoothedversionoftheextractedcorticalsurfacecanbeusedinthecompensationforelectrodedisplacementduetobrainshift(Step22).Moreover,FreeSurferautomaticallyregistersthesubject'sbraintoatemplatebrainonthebasisofitscorticalgyrificationpattern,anaspectofbrainstructurethatremainsdifficulttoaccuratelynormalizeusingvolume-basedregistrationtechniquesduetoitscomplexityandvariabilityacrosssubjects36,37.Ourprotocolusestheresultingsurfaceregistrationmapstolinkelectrodepositionstotheirtemplatehomologues(Step29).Finally,FreeSurfer-generatedatlasesareconvenientforrepresentationsofneuralandanatomicaldataforasinglesubject(Step52),sincetheyaredefinedinnativesubjectspace.Othersupportedatlasesaredefinedinstandardized(e.g.,MNI)spaceandrequiretheaddedstepoftransformingelectrodepositionstothatspace.HumanintracranialdataAnatomicalimages,typicallyMRIandCTscans,areusedaspartoftheepilepsydiagnosticandsurgicalprocedures.Apre-implantMRIshowstheanatomyoftheheadincludingthebrainandisusedtoidentifystructuralabnormalities.AnMRIisalsoinstrumentalinguidingSEEGelectrodeimplantationsubsequenttotheclinicaldecisiontorecordintracranially.Apost-implantCTshowshigh-intensityobjectssuchastheelectrodesandskullbutlacksdetailsofbrainanatomy.Toobtainknowledgeofanelectrode’slocationinrelationtothebrain’sanatomy,thetwoscanshavetobefused. Followingfusionofthepre-andpostoperativeanatomicalimages,electrodesthathavebeensurgicallyplacedonthecorticalsurfaceoccasionallyappear“buried”withinthecorticaltissue,sometimesmorethanacentimeterdeep38–43.Thiselectrodedisplacementistypicallydueto"brainshift",theinwardsinkingofthebrainpost-implantmostcommonlyobservedwithelectrocorticographicsurfacegridelectrodes.Thebrainshiftreflectstissuedisplacement,causedbytheelectrodesthemselves,andbysubduralfluidlossoraccumulation.Asnoted,thedisplacementismostpronounceddirectlybelowacraniotomyandisusuallyminimalforimplantssolelyinvolvingburrholes43.Itisimportanttoaccountforthisbrainshiftinordertoaccuratelyalignelectrodespecificsignalswiththelocalcorticalanatomy.Severallabshavedevelopedrealignmenttechniquestocompensateforelectrodedisplacementduetobrainshift,reducinglocalizationerrortounder3mmwhencomparedtointraoperativephotographs11,23–30.Ourprotocolcurrentlysupportstwoofthesetechniquestoprojectelectrodegridsbacktothecorticalsurfacewhileaccountingforagrid'sshapeandorientation23,30. Electrodelocalizationcanalsobedoneusingpost-implantMRIs,althoughthesearenotcommonlyacquiredinaclinicalsetting.Thesescansshowthebrainanatomyafterelectrodeimplantation,sobrainshiftisnotanissue.InaT1-weightedMRI,electrodesappeardark,duetothemagneticsusceptibilityartifact.Thisisgenerallynotanissueforrecordingswithdepthelectrodes(SEEG),wheretheelectrodesarevisibleasdarkvoidsinthehigherintensitybraintissue.Electrode

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 6: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

gridsandstrips(ECoG),ontheotherhand,areplaceddirectlyonthecorticalsurface.Thiscomplicatestheiridentification,astheelectrodesaresurroundedbycerebralspinalfluid,whichalsoappearsdarkonaT1scan(butsee25,44–46forworkarounds).Dependingontheavailabilityofapost-implantMRIofsufficientqualitythatclearlyshowstheelectrodes,theCTpreprocessingandfusionSteps9-15maybeleftout,andelectrodelocalizationmaybedoneonthepost-implantMRI.However,ifthepost-implantMRIisofunsatisfactoryqualityregardingbrainanatomy,forinstanceduetoelectrodeinducedMRsignaldistortion,werecommendfusingthepost-implantMRIwiththepre-implantMRI,asifitwereapost-implantCT. Neuralrecordingsaretypicallypartoftheongoingclinicalmonitoringandcomeinvariousfileformats.Eachdatachannelrepresents,asafunctionoftime,theelectricpotentialdifference,obtainedwitheitherabipolarorreferentialelectrodescheme.Thatis,theelectrodesarepairwiselinkedorreferencedtoasingle,commonelectrodeduringacquisition.Thelattermontagehasthebenefitthattherecordingscanbeeasilyre-montagedtoamorepreferredschemeintheofflineanalysis47.Themarkersortriggersforstimulusonsettimesandresponsesaretypicallyrecordedsimultaneouslyinadedicatedchannel,allowingforprecisesynchronizationofexperimentalscenarioswiththeneuralrecording.OverviewoftheprocedureTheprotocolisgroundedintwoparallelbutinterrelatedworkflows,asshowninFigure1.Thefirstworkflowentailstheprocessingofanatomicaldata.Itsmainactivitiesconstitutethepreprocessingandfusionoftheanatomicalimages,andelectrodeplacement(Steps1-19).SecondaryactivitiesthatarealsodiscussedincludecorticalsurfaceextractionwithFreeSurfer,brainshiftcompensation,spatialnormalization,andanatomicallabeling(Steps6and20-33).Generally,theanatomicalworkflowaimstoobtainestimatesoftheelectrodelocationsinrelationtotheindividualandatlas-basedbrainanatomy,whichisaone-timeprocedureforeachsubject.Thesecondworkflowfocusesonimprovingthesignal-to-noiseratioandextractingtherelevantfeaturesfromtheelectrophysiologicaldata,whilepreparingforsubsequentanalyses.Itminimallyencompassesthepreprocessingoftheneuralrecordings,butmayalsoincludefollow-upactivitiessuchastime-frequencyandsingle-subjectorgroup-levelstatisticalanalysis(Steps34-45).Generally,thespecificsofthefunctionalworkflowdependultimatelyontheclinicalorresearchquestionathandandcontingenciesintheexperimentalparadigm. Thetwoworkflowsbecomeintrinsicallyconnectedforthefirsttimeduringtheelectrodeplacementactivity(Step17),whichofferstheopportunitytodirectlylinkanatomicallocationstoelectrodelabelscorrespondingtotheneuralrecordings.Thisactivityinvolvesaninteractiveelectrodeplacementtooldesignedforefficientyetpreciseidentificationofelectrodesineventhemostchallengingcases.Theintegrationofthetwoworkflowsculminatesinaninteractiveandanatomicallyinformeddataexplorationtoolandtheabilitytorepresentfunctionalandepileptiformneuralactivityoverlaidoncorticalandsubcorticalsurfacemodels,infigureorvideoformat(Steps46-56).

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 7: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

ImplementationandadaptationoftheprocedureAllimplementationsrunonasingleuniversalplatform(MATLAB,exceptforFreeSurfer)tosupportrelativelyeasilyautomatedproceduresfordealingwithrepeatedanalyseswithinandacrosssubjects.Werecommendthattheuserconstructasinglescriptforasinglesubjectbyincrementallycopy-pastingcodefromthisprotocolintotheMATLABeditor(SupplementaryFile1),andevaluatingsegmentsofthatscriptintheMATLABcommandwindow.Oncethescriptproducessatisfactoryresults,itcanbeconvertedintoabatchanalysisbybreakingitintoseparatecomponents.Byloopingaroundtheseparatecomponentsforallsubjects,theentireanalysispipelineforallsubjectsinastudycaneasilybeexecutedandintermediateresultscanbesavedandevaluated. Thewholebatchcanbedocumentedandshared,orre-evaluatedwithdifferentparametersettingsasappropriate.Byvirtueofchangingsingleparametersatafunctioncall,onecanforinstancereadilyalternatebetweenvariousfusion,localization,projection,normalization,filtering,re-montaging,andspectralestimationalgorithmstoaccommodatedifferentcasesandsituations.Theoutputdatastructuresarekeptconsistentacrossthedifferentalgorithms,andtheparameterstotheusedalgorithmareappendedtoallowforaccesstothefulldataprovenanceatanyleveloftheanalysispipeline(Box1).ExperimentaldesignTheexampleiEEGdatasetwasacquiredattheMedicalCenteroftheUniversityofCalifornia,Irvine.TheOfficefortheProtectionofHumanSubjectsoftheUniversityofCalifornia,Berkeley,approvedthestudyandthesubjectgaveinformedconsent.Thedatasetincludesapre-implantMRI,apost-implantCT,apost-implantMRI,andneuralrecordingsfrom96ECoGand56SEEGelectrodesthatwereimplantedaspartofthepreparationfortheepilepsysurgery(seeMaterials).Theneuraldatawererecordedinthecontextofanexperimentthatrequiredthepatienttopressabuttonwiththerighthandwhenhearingatargettone.Theoriginaldataset(afterdefacingtheimagingdatawithft_defacevolume)andtheprocessedresultsareavailablefordownloadfromftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/SubjectUCI29.zip.RawDICOMimagesandrecordingfilesarenotsharedtoprotectthesubject'sidentity. WechoosethisiEEGdatasetforthreereasons.First,itcontainsneuralrecordingsfrombothcorticalgrid(ECoG)andstereotacticallyinserteddepthelectrodes(SEEG),requiringstrategiesfordealingwitheachtypeaswellastheircombinationintheanalysis.Second,thepre-implantMRIisnotofthebestquality(acontrastagentwasused),electrodesofadjacentcorticalgridshaveseeminglymergedwithoneanotherinthepost-implantCT,andthereissignificantelectrodedisplacementduetoasubduralhygromacontributingtobrainshift.Theseissuesreflectrealworldchallengesinintracranialdataanalysis,allowingustodemonstratetheapplicationofourprotocoltonon-idealdata.Finally,theexperimentalparadigmissimpleenoughtoneednofurtherexplanation,yetrequiresperformingallthefundamentalstepsunderlyingtheanalysisofintracranialdatarecordedusingamorecomplexexperimentalparadigm19,48.Wedemonstratetheanalysisoftask-relatedhigh-frequency-bandactivity(~70to150

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 8: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Hz),aprominentneuralsignatureinintracranialdatathathasbeenassociatedwithneuronpopulationlevelfiringrate5,49–52.Manyothersupportedanalysessuchasevent-relatedpotentialanalysis,connectivityanalysis,andstatisticalanalysishavebeendescribedindetailelsewhere53–55.

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 9: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

MATERIALSAnatomicalimages

• Pre-implantT1-weightedMRI(MagneticResonanceImage,Siemens3TTrioTim).

• Post-implantCT(ComputerizedTomography,PhilipsiCT256).• Post-implantT1-weightedMRI(MagneticResonanceImage,Siemens1.5T

Avanto).Thisscanisnotusedintheprocedurebutneverthelessincludedforcompleteness.

Neuralrecordings• 64-contactcorticalgridwithleftparietalcoverage(Integra,8x8layout,10

mminter-electrodespacing,labelshaveaLPGprefix)• 32-contactcorticalgridwithlefttemporalcoverage(Integra,4x8layout,10

mminter-electrodespacing,labelshaveaLTGprefix)• 8-contactlineardepthelectrodetargetingleftamygdala(Ad-Tech,5mm

inter-electrodespacing,labelshaveaLAMprefix)• 8-contactlineardepthelectrodetargetinglefthippocampushead(Ad-Tech,5

mminter-electrodespacing,labelshaveaLHHprefix)• 8-contactlineardepthelectrodetargetinglefthippocampustail(Ad-Tech,5

mminter-electrodespacing,labelshaveaLTHprefix)• 8-contactlineardepthelectrodetargetingrightamygdala(Ad-Tech,5mm

inter-electrodespacing,labelshaveaRAMprefix)• 8-contactlineardepthelectrodetargetingrighthippocampushead(Ad-Tech,

5mminter-electrodespacing,labelshaveaRHHprefix)• 8-contactlineardepthelectrodetargetingrighthippocampustail(Ad-Tech,5

mminter-electrodespacing,labelshaveaRTHprefix)• 8-contactlineardepthelectrodetargetingrightoccipitalcortex(Ad-Tech,5

mminter-electrodespacing,labelshaveaROCprefix)• AllneuralrecordingswereacquiredusingaNihonKohdenrecordingsystem

withaJE-120Aamplifier(NihonKohdenCorporation,Tokyo,Japan),analog-filteredabove0.01Hz,anddigitallysampledat5KHz

Software• MATLABenvironment(MathWorks,Natick,MA;installationandlicensing

throughhttp://www.mathworks.com)• FieldTriptoolbox(Box1,freelyavailableathttp://www.fieldtriptoolbox.org)• FreeSurfersoftwaresuiteforcorticalsurfaceextraction(optional;freely

availableathttp://www.freesurfer.net)Supportedanatomicaldataformats

• AFNI(*.head,*.brik)• Analyze(*.img,*.hdr)• ANT(*.mri)• DICOM(*.dcm,*.ima)• FreeSurfer(*.mgz,*.mgh)• MINC(*.mnc)• NIfTI(*.nii,*.nii.gz)

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 10: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Supportedelectrophysiologicaldataformats• Anywave(*.ah5)• BCI2000(*.dat)• BESA(*.besa)• Blackrock(*.nev,*.ns#)• CambridgeElectronicDesign(*.smr)• EuropeanDataFormat(*.edf)• GTec(*.mat,*.hdf5)• Micromed(*.trc)• Neuralynx(*.ncs,*.nse,*.nts,*.nst,*.ntt,*.nev)• Neuromag(*.fif)• Neuroscope(*.eeg,*.dat,*.xml)• NihonKohden(*.m00)• Plexon(*.ddt,*.nex,*.plx)• andvariousEEG,MEG,NIRS,andeye-trackerdataformats

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 11: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

PROCEDURE1|SpecifythesubjectID.ThisIDwillbeusedinthefilenaming,inadditiontoinformationaboutthetypeofdata(e.g.,MRI,CT),thecoordinatesystemitisin(e.g.,ACPC,MNI),andtheprocess(es)thatwereappliedtoit(e.g.,fforfusion).Forexample,aCTscanthatisalignedtotheACPCcoordinatesystemandthathasjustbeenfusedwiththeanatomicalMRIiswrittenouttofileassubjID_CT_acpc_f.nii. subjID='SubjectUCI29';PreprocessingoftheanatomicalMRI,TIMING~2min2|ImporttheanatomicalMRIintotheMATLABworkspaceusingft_read_mri.TheMRIcomesintheformatofasinglefilewithan.imgor.niiextension,orafoldercontainingaseriesoffileswitha.dcmor.imaextension(DICOM;SupplementaryFile2mayaidinthesearchandvisualizationofaDICOMseries).

mri=ft_read_mri(<pathtoMRIfile>);

3|DeterminethenativeorientationoftheanatomicalMRI'sleft-rightaxisusingft_determine_coordsys(Box2andSupplementaryVideo1).CRITICALSTEPTocorrectlyfusetheMRIandCTscansatalaterstep,accuracyindemarcatingtherighthemispherelandmarkinthefollowingstepisimportantforavoidinganotherwisehardtodetectflipofthescan'sleftandrightorientation.4|AligntheanatomicalMRItotheACPCcoordinatesystem56,apreferredconventionfortheFreeSurferoperationoptionallyusedinalaterstep.Inthiscoordinatesystem,theorigin(coordinate[0,0,0])isattheanteriorcommissure(AC),theY-axisrunsalongthelinebetweentheanteriorandposteriorcommissure(PC),andtheZ-axisliesinthemidlinedividingthetwocerebralhemispheres.Specifytheanteriorandposteriorcommissure,aninterhemisphericlocationalongthemidlineatthetopofthebrain,andalocationinthebrain’srighthemisphere.Ifthescanwasfoundtohavealeft-to-rightorientationinthepreviousstep,therighthemisphereisidentifiedasthehemispherehavinglargervaluesalongtheleft-rightaxis.Viceversa,inaright-to-leftsystem,therighthemispherehassmallervaluesalongthataxisthanitsleftcounterpart(SupplementaryVideo2).

cfg=[];cfg.method='interactive';cfg.coordsys='acpc';mri_acpc=ft_volumerealign(cfg,mri);

5|WritethepreprocessedanatomicalMRIouttofile.

cfg=[];cfg.filename=[subjID'_MR_acpc'];cfg.filetype='nifti';cfg.parameter='anatomy';

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 12: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

ft_volumewrite(cfg,mri_acpc);CorticalsurfaceextractionwithFreeSurfer(optional),TIMING~10hrs,automatic6|ExecuteFreeSurfer'srecon-allfunctionalityfromtheLinuxorMacOSterminal(WindowsviaVirtualBox),orfromtheMATLABcommandwindowasbelow.Thissetofcommandswillcreateafoldernamed‘freesurfer’inthesubjectdirectory,withsubdirectoriescontainingamultitudeofFreeSurfer-generatedfiles.

fshome=<pathtofreesurferhomedirectory>;subdir=<pathtosubjectdirectory>;mrfile=<pathtosubjectMR_acpc.nii>;system(['exportFREESURFER_HOME='fshome';'...

'source$FREESURFER_HOME/SetUpFreeSurfer.sh;'... 'mri_convert-c-oc000'mrfile''[subdir'/tmp.nii']';'... 'recon-all-i'[subdir'/tmp.nii']'-s''freesurfer''-sd'subdir'-all'])PAUSEPOINTFreeSurfer'sfullyautomatedsegmentationandcorticalextractionoftheanatomicalMRIcurrentlymaytakeup10hoursormore.Fortutorialpurposes,theexampledatasetcontainstheoutputfromFreeSurfer,afoldernamed'freesurfer',forcontinuationwiththeprotocol. 7|ImporttheextractedcorticalsurfacesintotheMATLABworkspaceandexaminetheirquality.Repeatthefollowingcodeusingrh.pialtovisualizethepialsurfaceoftherighthemisphere.

pial_lh=ft_read_headshape(<pathtofreesurfer/surf/lh.pial>);pial_lh.coordsys='acpc';ft_plot_mesh(pial_lh);lightinggouraud;camlight;

?TROUBLESHOOTING8|ImporttheFreeSurfer-processedMRIintotheMATLABworkspaceforthepurposeoffusingwiththeCTscanatalaterstep,andspecifythecoordinatesystemtowhichitwasalignedinStep4.

fsmri_acpc=ft_read_mri(<pathtofreesurfer/mri/T1.mgz>); fsmri_acpc.coordsys='acpc';PreprocessingoftheanatomicalCT,TIMING~2min9|ImporttheanatomicalCTintotheMATLABworkspace.SimilartotheMRI,theCTscancomesintheformatofasinglefilewithan.imgor.niiextension,orafolder

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 13: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

containingaseriesoffileswitha.dcmor.imaextension(SupplementaryFile2mayaidinthesearchandvisualizationofaDICOMseries).

ct=ft_read_mri(<pathtoCTfile>);10|Incasethiscannotbedoneonthebasisofknowledgeofthelateralityofelectrodeimplantation,determinethenativeorientationoftheanatomicalCT'sleft-rightaxisusingft_determine_coordsys,similarlytohowitwasdonewiththeanatomicalMRIinStep3(Box2andSupplementaryVideo1).CRITICALSTEPTocorrectlyfusetheMRIandCTscansatalaterstep,accuracyindemarcatingtherightandleftpreauricularlandmarkinthefollowingstepisimportantforavoidinganotherwisehardtodetectflipofthescan'sleftandrightorientation.11|AligntheanatomicalCTtotheheadsurfacecoordinatesystembyspecifyingthenasion(attherootofthenose),leftandrightpreauricularpoints(justinfrontoftheearcanals),andaninterhemisphericlocationalongthemidlineatthetopofthebrain(SupplementaryVideo3).TheCTscanisinitiallyalignedtotheheadsurfacecoordinatesystem,giventhattheACPCcoordinatesystemusedfortheMRIreliesonneuroanatomicallandmarksthatarenotvisibleintheCT.

cfg=[];cfg.method='interactive';cfg.coordsys='ctf';ct_ctf=ft_volumerealign(cfg,ct);

12|AutomaticallyconverttheCT'scoordinatesystemintoanapproximationoftheACPCcoordinatesystem,thesamesystemtheanatomicalMRIwasalignedto.

ct_acpc=ft_convert_coordsys(ct_ctf,'acpc');FusionoftheCTwiththeMRI,TIMING~3min13|FusetheCTwiththeMRI,anecessarysteptolinktheelectrodelocationsintheanatomicalCTtotheircorrespondinglocationsintheanatomicalMRI57,58.Giventhatbothscansarefromthesamesubjectandtheircommondenominatoristheskull,arigidbodytransformationsufficesfortheiralignmentundernormalcircumstances(thedefaulttechniquewhenusingtheSPM-methodinFieldTrip).

cfg=[];cfg.method='spm';cfg.spmversion='spm12';cfg.coordsys='acpc';cfg.viewresult='yes';ct_acpc_f=ft_volumerealign(cfg,ct_acpc,fsmri_acpc);

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 14: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

14|Carefullyexaminetheinteractivefigurethatisproducedafterthecoregistrationiscompleted,showingtheMRIandfusedCTsuperimposed.AsuccessfulfusionwillshowtightinterlockingofCT-positiveskull(inblue)andMRI-positivebrainandskintissue(inred).CRITICALSTEPAccuracyofthefusionoperationisimportantforcorrectlyplacingtheelectrodesinanatomicalcontextinafollowingstep.?TROUBLESHOOTING15|WritetheMRI-fusedanatomicalCTouttofile.

cfg=[];cfg.filename=[subjID'_CT_acpc_f'];cfg.filetype='nifti';cfg.parameter='anatomy';ft_volumewrite(cfg,ct_acpc_f);

Electrodeplacement,TIMING~15min16|Importtheheaderinformationfromtherecordingfile,ifpossible.Bygivingtheelectrodelabelsoriginatingfromtheheaderasinputtoft_electrodeplacementinthenextstep,thelabelswillappearasato-dolistduringtheinteractiveelectrodeplacementactivity.Asecondbenefitisthattheelectrodelocationscanbedirectlyassignedtolabelscollectedfromtherecordingfile,obviatingtheneedtosortandrenameelectrodestomatchtheelectrophysiologicaldata.

hdr=ft_read_header(<pathtorecordingfile>);

17|Localizetheelectrodesinthepost-implantCTwithft_electrodeplacement,showninFigure2.Clickinganelectrodelabelinthelistwilldirectlyassignthatlabeltothecurrentcrosshairlocation(SupplementaryVideo4).Severalin-appfeaturesfacilitateefficientyetprecisenavigationoftheanatomicalimage,suchasazoommode,amagnetoptionthattransportsthecrosshairtothenearestweightedmaximumwithsubvoxelaccuracy(orminimumincaseofapost-implantMRI),andaninteractivethree-dimensionalscatterfigurethatislinkedtothetwo-dimensionalvolumerepresentations.Furthermore,passingonthepre-implantMRI,fsmri_acpc,toft_electrodeplacementallowstogglingbetweenCTandMRIviewsfortheidentificationofspecificelectrodesbasedontheiranatomicallocation.Generally,electrode#1istheelectrodefarthestawayfromthecraniotomyorburrholeincaseofdepthsandsingle-rowstrips.Carefulnotestakenduringsurgeryandrecordingarecriticalfordeterminingthenumberingofgridandmulti-rowstripelectrodes.

cfg=[];cfg.channel=hdr.label;elec_acpc_f=ft_electrodeplacement(cfg,ct_acpc_f,fsmri_acpc);

18|Examinewhetherthevariablesinresultingelectrodestructureelec_acpc_fmatchtherecordingparameters,e.g.,thenumberofchannelsstoredinthelabel

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 15: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

field.Theelectrodeandchannelpositionsarestoredintheelecposandchanposfields,respectively.Theelecposfieldcontainstheoriginalelectrodepositions.Withexceptionofpossiblebrainshiftcompensation,thisfieldisnotadjusted.Thechannelpositionsinthechanposfieldareinitiallyidenticaltotheelectrodepositionsbutmaybeupdatedtoaccommodateofflineadjustmentsinchannelcombinations,i.e.duringre-montaging.ForbipolariEEGdata,thebestconsideredchannelpositionisinbetweenthetwocorrespondingelectrodepositions.Thechanposfieldisusedforoverlayingtheneuraldataon(sub-)corticalmodelsduringdatavisualization.Thetrafieldisamatrixwiththeweightofeachelectrodeintoeachchannel,whichatthisstagemerelyisanidentitymatrixreflectingone-to-onemappingsbetweenelectrodesandchannels. elec_acpc_f= unit:'mm' coordsys:‘acpc’ label:{152x1cell}elecpos:[152x3double]chanpos:[152x3double]tra:[152x152double] cfg:[1x1struct]19|Savetheresultingelectrodeinformationtofile.

save([subjID'_elec_acpc_f.mat'],'elec_acpc_f');Brainshiftcompensation(optionalforcorticalgridsandstrips),TIMING~5min21|Incaseof"brainshift",adisplacementofbraintissueandelectrodespost-implant,realignmentofelectrodegridstothepreoperativecorticalsurfacemaybenecessary.Topreventelectrodesfrombeingincorrectlyplacedinthenearbycorticalsulciduringback-projection,createasmoothhullaroundthecorticalsurfacegeneratedbyFreeSurfer59.

cfg=[];cfg.method='cortexhull';

cfg.headshape=<pathtofreesurfer/surf/lh.pial>; cfg.fshome=<pathtofreesurferhomedirectory>;hull_lh=ft_prepare_mesh(cfg);21|Savethehulltofile.

save([subjID'_hull_lh.mat'],hull_lh);22|Projecttheelectrodegridstothesurfacehulloftheimplantedhemisphere.Giventhatdifferentgridscanmoveindependentlyfromoneanotherandthattheprojectionalgorithmspecifiedincfg.warpconsiderstheglobalelectrode

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 16: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

configurationofagrid30,itisrecommendedtorealignelectrodegridsindividuallybyrunningseparaterealignmentproceduresforeachgrid.Here,werealigntheelectrodesoftheleftparietalgridfollowedbytheelectrodesofthelefttemporalgrid(LPGandLTGrespectively)andstoretheupdatedgridelectrodeinformationinanewvariabletogetherwiththeunalteredcoordinatesofthedepthelectrodes. elec_acpc_fr=elec_acpc_f; grids={'LPG*','LTG*'}; forg=1:numel(grids) cfg=[]; cfg.channel=grids{g}; cfg.keepchannel='yes'; cfg.elec=elec_acpc_fr; cfg.method='headshape'; cfg.headshape=hull_lh; cfg.warp='dykstra2012'; cfg.feedback='yes'; elec_acpc_fr=ft_electroderealign(cfg); end23|Visualizethecortexandelectrodestogetherandexaminewhethertheyshowexpectedbehavior(Fig.3).CRITICALSTEPAccuracyoftherealignmentoperationisimportantforcorrectlyplacingtheelectrodesinanatomicalcontextinafollowingstep.

ft_plot_mesh(pial_lh);ft_plot_sens(elec_acpc_fr);view([-5510]);materialdull;lightinggouraud;camlight;

?TROUBLESHOOTING24|Savetheupdatedelectrodeinformationtofile.

save([subjID'_elec_acpc_fr.mat'],'elec_acpc_fr');Volume-basedregistration(optional),TIMING~2min25|TogeneralizetheelectrodecoordinatestootherbrainsorMNI-basedneuroanatomicalatlasesinalaterstep,registerthesubject'sbraintothestandardMNIbrain.Thevolume-basedregistrationtechniqueconsiderstheoverallgeometryofthebrain60andcanbeusedforthespatialnormalizationofalltypesofelectrodes,whetherdepthoronthesurface.

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 17: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

cfg=[];cfg.nonlinear='yes';cfg.spmversion='spm12';

fsmri_mni=ft_volumenormalise(cfg,fsmri_acpc);26|UsetheresultingdeformationparameterstoobtaintheelectrodepositionsinstandardMNIspace.

elec_mni_frv=elec_acpc_fr;elec_mni_frv.elecpos=ft_warp_apply(fsmri_mni.params,elec_acpc_fr.elecpos,

'individual2sn');elec_mni_frv.chanpos=ft_warp_apply(fsmri_mni.params,elec_acpc_fr.chanpos,

'individual2sn');elec_mni_frv.coordsys='mni';

27|VisualizethecorticalmeshextractedfromthestandardMNIbrainalongwiththespatiallynormalizedelectrodesandexaminewhethertheyshowexpectedbehavior(toprightinFig.4).CRITICALSTEPAccuracyofthespatialnormalizationstepisimportantforcorrectlyoverlayingtheelectrodepositionswithabrainatlasinafollowingstep.

load(<pathtofieldtrip/template/anatomy/surface_pial_left.mat>);ft_plot_mesh(mesh);ft_plot_sens(elec_mni_frv);view([-9020]);materialdull;lightinggouraud;camlight;

?TROUBLESHOOTING28|Savethenormalizedelectrodeinformationtofile.

save([subjID'_elec_mni_frv.mat'],'elec_mni_frv');Surface-basedregistration(optionalforsurfaceelectrodes),TIMING~2min29|Togeneralizetheelectrodecoordinatestootherbrainsinalaterstep,maptheelectrodesontoFreeSurfer'sfsaveragebrain.Thesurface-basedregistrationtechniquesolelyconsidersthecurvaturepatternsofthecortex35andthuscanbeusedforthespatialnormalizationofelectrodeslocatedonornearthecorticalsurface.Intheexamplecase,thispertainstoallelectrodesoftheleftparietalandtemporalgrids.

cfg=[];cfg.channel={'LPG*','LTG*'};

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 18: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

cfg.elec=elec_acpc_fr;cfg.method='headshape';

cfg.headshape=<pathtofreesurfer/surf/lh.pial>;cfg.warp='fsaverage';cfg.fshome=<pathtofreesurferhomedirectory>;

elec_fsavg_frs=ft_electroderealign(cfg);30|VisualizeFreeSurfer'sfsaveragebrainalongwiththespatiallynormalizedelectrodesandexaminewhethertheyshowexpectedbehavior(bottomrightinFig.4).CRITICALSTEPAccuracyofthespatialnormalizationstepisimportantforcorrectlyoverlayingtheelectrodepositionswithabrainatlasinafollowingstep.

fspial_lh=ft_read_headshape(<pathtofshome/subjects/fsaverage/surf/lh.pial>);

fspial_lh.coordsys='fsaverage';ft_plot_mesh(fspial_lh);ft_plot_sens(elec_fsavg_frs);view([-9020]);materialdull;lightinggouraud;camlight;

31|Savethenormalizedelectrodeinformationtofile.

save([subjID'_elec_fsavg_frs.mat'],'elec_fsavg_frs');

Anatomicallabeling(optional),TIMING~1min32|FieldTripsupportslookinguptheanatomicalorfunctionallabelscorrespondingtotheelectrodesinanumberofatlases,includingtheAFNITalairachTournouxatlas61,theAALatlas62,theBrainWebdataset63,theJuBraincytoarchitectonicatlas64,theVTPMatlas65,andtheBrainnetomeatlas66,inadditiontothesubject-tailoredDesikan-KillianyandDestrieuxatlasesproducedbyFreeSurfer67,68.WithexceptionoftheaboveFreeSurfer-basedatlases,theseatlasesareinMNIcoordinatespaceandrequiretheelectrodestobespatiallynormalized(Step25).First,importanatlasofinterest,e.g.,theAALatlas,intotheMATLABworkspace.

atlas=ft_read_atlas(<pathtofieldtrip/template/atlas/aal/ROI_MNI_V4.nii>);33|Lookupthecorrespondinganatomicallabelofanelectrodeofinterest,e.g.,electrodeLHH2,targetingthelefthemisphere’shippocampus.SupplementaryFile3representsatoolthatautomaticallyoverlaysallchannelsinanelectrodestructurewithalloftheaboveatlasesandstorestheresultinganatomicallabelsinanexceltable(e.g.,SubjectUCI29_electable.xlsxinthezipfile).

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 19: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

cfg=[]; cfg.roi =elec_mni_frv.chanpos(match_str(elec_mni_frv.label, 'LHH2'),:); cfg.atlas =atlas; cfg.inputcoord='mni'; cfg.output='label';

labels=ft_volumelookup(cfg,atlas);

[~,indx]=max(labels.count); labels.name(indx)

ans='ParaHippocampal_L'

?TROUBLESHOOTING

Preprocessingoftheneuralrecordings,TIMING~10min34|Definethetrials,thatis,thesegmentsofdatathatwillbeusedforfurtherprocessingandanalysis.Thisstepproducesamatrixcfg.trlcontainingforeachsegmentthebeginandendsampleintherecordingfile.Inthecaseoftheexampleprovidedintheshareddata,thesegmentsofinterestbegin400msbeforetoneonset,aremarkedwitha‘4’inthetriggerchannel,andend900msthereafter.

cfg=[];cfg.dataset=<pathtorecordingfile>;cfg.trialdef.eventtype=‘TRIGGER′;cfg.trialdef.eventvalue=4;cfg.trialdef.prestim=0.4;cfg.trialdef.poststim=0.9;cfg=ftdefinetrial(cfg);

35|ImportthedatasegmentsofinterestintotheMATLABworkspaceandfilterthedataforhigh-frequencyandpowerlinenoise(seethedocumentationofft_preprocessingforfilteringoptions).

cfg.demean ='yes';cfg.baselinewindow='all';cfg.lpfilter='yes';cfg.lpfreq=200;cfg.padding=2;cfg.padtype='data';cfg.bsfilter='yes';cfg.bsfiltord=3;cfg.bsfreq=[5961;119121;179181];data=ft_preprocessing(cfg);

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 20: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

36|Examinewhetherthevariablesintheoutputdatastructurematchtherecordingandpreprocessingparameters,i.e.thesamplingrate(fsample),numberofrecordingchannels(label),andsegmentationintotheexperiment’stwenty-sixtrials(trial,andtheirrespectivetimeaxesintime).

data=label:{152x1cell}time:{1x26cell}trial:{1x26cell}fsample:5000

sampleinfo:[26x2double]cfg:[1x1struct]37|Addtheelecstructureoriginatingfromtheanatomicalworkflowandsavethepreprocessedelectrophysiologicaldatatofile.Theadvantageofaddingtheelectrodeinformationatthisstageisthatitwillbekeptconsistentwiththeneuraldatagoingforward,aswhenapplyingthesamemontageusedfortheneuralrecordingstothechannelpositions. data.elec=elec_acpc_fr;

save([subjID'_data.mat'],'data');38|Inspecttheneuralrecordingsusingft_databrowserandidentifychannelsorsegmentsofnon-interest,forinstancesegmentscontainingsignalartifactsor(inthiscase)epileptiformactivity.Markthebadsegmentsbydrawingaboxaroundthecorruptedsignal.Writedownthelabelsofbadchannels.CRITICALSTEPIdentifyingbadchannelsisimportantforavoidingthecontaminationofotherchannelsduringre-montaginginStep40. cfg=[]; cfg.viewmode='vertical'; cfg=ft_databrowser(cfg,data);39|Removeanybadsegmentsmarkedintheabovestep. data=ft_rejectartifact(cfg,data);40|Re-montagethecorticalgridstoacommonaveragereferenceinordertoremovenoisethatissharedacrossallchannels.Box3providesabackgroundonre-montaging.BadchannelsnotedinStep38canbeexcludedfromthisstepbyaddingthosechannelstocfg.channelwithaminusprefix.Thatis,cfg.channel={'LPG*','LTG*','-LPG1'}ifoneweretoexcludetheLPG1channelfromthelistofLPGandLTGchannels.

cfg=[];cfg.channel={'LPG*','LTG*'};

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 21: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

cfg.reref ='yes';cfg.refchannel='all';reref_grids=ft_preprocessing(cfg,data);

41|Applyabipolarmontagetothedepthelectrodes.ThiscanbedoneinasimilarmannerasinStep40,butbyselectingsinglechannellabelsforcfg.channelandcfg.refchannel.Alternatively,createamoreelaborateschemewithcfg.montage(seethedocumentationofft_apply_montage).Here,wecombineforeachdepthelectrodeshaftthe8unipolarchannelsinto7bipolarchannels,usingtheweightsdefinedinthe7x8montage.trafield.Wealsocreatenewlabelsindicatingthebipolaroriginofthedata,e.g.,“RAM1-RAM2”,“RAM2-RAM3”,andsoon.NotethatbecauseweaddedtheelecstructuretothedatainStep37,thesamemontageisautomaticallyappliedtothechannelpositionsaswell,withtheresultingchanposfieldcontainingthemeanlocationsofallelectrodepairsthatcompriseabipolarchannel.

depths={'RAM*','RHH*','RTH*','ROC*','LAM*','LHH*','LTH*'};ford=1:numel(depths)cfg=[];cfg.channel=ft_channelselection(depths{d},data.label);

cfg.montage.labelold=cfg.channel; cfg.montage.labelnew=strcat(cfg.channel(1:end-1),'-',cfg.channel(2:end)); cfg.montage.tra=... [1-1000000 01-100000 001-10000 0001-1000 00001-100 000001-10 0000001-1]; cfg.updatesens='yes'; reref_depths{d}=ft_preprocessing(cfg,data);

end42|Combinethedatafrombothelectrodetypesintoonedatastructurefortheeaseoffurtherprocessing.

cfg=[];cfg.appendsens='yes';reref=ft_appenddata(cfg,reref_grids,reref_depths{:});

43|Savethere-referenceddatatofile.

save([subjID'_reref.mat'],reref);

Time-frequencyanalysis(optional),TIMING~2min

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 22: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

44|Decomposethesignalintimeandfrequencybins.Theconfigurationoptionscfg.foiandcfg.toideterminethefrequenciesandtime-pointsofinterest,inthiscasefrom5to200Hzinstepsof5Hz,and300mspriortotoneonsetuntil800msthereafterinstepsof10ms.

cfg=[];cfg.method='mtmconvol';cfg.foi=5:5:200;cfg.toi=-.3:0.01:.8;cfg.t_ftimwin=ones(length(cfg.foi),1).*0.2;cfg.taper='hanning';cfg.output='pow';freq=ft_freqanalysis(cfg,reref);

45|Savethetime-frequencydatatofile.

save([subjID'_freq.mat'],'freq');Interactiveplotting,TIMING~3min46|Forananatomicallyinformedexplorationofthemultidimensionaloutcomeofananalysis,createalayoutbasedonthethree-dimensionalelectrodelocations.Thislayoutisasymbolicrepresentationinwhichthechannelsareprojectedonthetwo-dimensionalmediumofferedbypaperoracomputerscreen.Thelayoutiscomplementedbyanautomaticoutlineofthecorticalsheetthatisspecifiedincfg.headshape.Thecfg.boxchanneloptionallowsselectingchannelswhosetwo-dimensionaldistancesareusedtodeterminetheplottingboxsizesinthefollowingstep.

cfg=[];cfg.headshape=pial_lh;cfg.projection='orthographic';cfg.channel={'LPG*','LTG*'};cfg.viewpoint='left';cfg.mask='convex';cfg.boxchannel={'LTG30','LTG31'};lay=ft_prepare_layout(cfg,freq);

47|Expressthetime-frequencyrepresentationofneuralactivityateachchannelintermsoftherelativechangeinactivityfromabaselineinterval.

cfg=[];cfg.baseline=[-.3-.1];cfg.baselinetype='relchange';freq_blc=ft_freqbaseline(cfg,freq);

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 23: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

48|Visualizethetime-frequencyrepresentationsoverlaidonthetwo-dimensionallayout.Thegeneratedfigureisinteractive,sothatselectingagroupofchannelswilllaunchanotherfigurerepresentingtheaveragetime-frequencyrepresentationoverthosechannels(Fig.5).Selectingacertainfrequencyandtimerangeinthattime-frequencyrepresentationwilllaunchyetanotherfigureshowingthetopographicaldistributionofactivityintheselectedinterval,andsoon(SupplementaryVideo5).

cfg=[];cfg.layout=lay;cfg.showoutline='yes';ft_multiplotTFR(cfg,freq_blc);

ECoGdatarepresentation,TIMING~1min49|Forananatomicallyrealisticrepresentationofcorticalactivity,overlayasurfacemodeloftheneocortexwiththespatialdistributionofthehighfrequency-bandactivity.First,extracthigh-frequency-bandactivityduringatimeintervalofinterest.

cfg=[];cfg.frequency=[70150];cfg.avgoverfreq='yes';cfg.latency=[00.8];cfg.avgovertime='yes';freq_sel=ft_selectdata(cfg,freq_blc);

50|Visualizethespatialdistributionofhigh-frequency-bandactivityonacorticalmeshofthesubject’sbrain.

cfg=[];cfg.funparameter='powspctrm';cfg.funcolorlim=[-.5.5];cfg.method='surface';cfg.interpmethod='sphere_weighteddistance';cfg.sphereradius=8;cfg.camlight='no';ft_sourceplot(cfg,freq_sel,pial_lh);view([-9020]);materialdull;lightinggouraud;camlight;

51|Addtheelectrodestothefigure(Fig.6).ByloopingaroundSteps49to51whilebreakingdownthetimeintervalofinterestspecifiedwithcfg.latencyinconsecutivesteps,itbecomesfeasibletoobservethespatiotemporaldynamicsofneuralactivityoccurringinrelationtoknownexperimentalstructureandbehavior

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 24: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

(SupplementaryVideo6).Seehelpgetframeforcapturingandassemblingtime-lapsemovies.

ft_plot_sens(elec_acpc_fr);SEEGdatarepresentation,TIMING~2min52|Fordepthrecordings,createanintegratedrepresentationofneuralactivityandanatomybyinterpolatingneuraldatafromeachbipolarchannelinasphericalcloud,whichcanthenbeoverlaidonasurfacemeshofanydeepbrainstructure.First,createavolumetricmaskoftheregionsofinterest(ROI).Here,wegenerateamaskfortherighthippocampusandamygdalafromthecorticalparcellationandsubcorticalsegmentationproducedbyFreeSurfer. atlas=ft_read_atlas('freesurfer/mri/aparc+aseg.mgz'); atlas.coordsys='acpc'; cfg=[]; cfg.inputcoord='acpc'; cfg.atlas=atlas; cfg.roi={'Right-Hippocampus','Right-Amygdala'}; mask_rha=ft_volumelookup(cfg,atlas);53|Createatriangulatedandsmoothedsurfacemeshonthebasisofthevolumetricmasks.

seg=keepfields(atlas,{'dim','unit','coordsys','transform'});seg.brain=mask_rha;cfg=[];cfg.method='iso2mesh';cfg.radbound=2;cfg.maxsurf=0;cfg.tissue='brain';cfg.numvertices=1000;cfg.smooth=3;mesh_rha=ft_prepare_mesh(cfg,seg);

54|Identifythesubcorticalelectrodesofinterest.

cfg=[];cfg.channel={'RAM*','RTH*','RHH*'};freq_sel2=ft_selectdata(cfg,freq_sel);

55|Interpolatethehigh-frequency-bandactivityinthebipolarchannelsonasphericalcloudaroundthechannelpositions,whileoverlayingtheneuralactivitywiththeabovemesh.Byrepeatingthecurrentstepforneuraldatacorrespondingtoconsecutivetimeintervals,similarlytotheprocessoutlinedinStep51,itbecomesfeasibletocreatetime-lapsemoviesofthespatiotemporaldynamicsofdeep-brain

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 25: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

activity(SupplementaryVideo7showsthespatiotemporalevolutionofepileptiformactivityinaseparatesubject). cfg=[]; cfg.funparameter='powspctrm'; cfg.funcolorlim=[-.5.5]; cfg.method='cloud'; cfg.slice='3d'; cfg.nslices=2; cfg.facealpha=.25; ft_sourceplot(cfg,freq_sel2,mesh_rha); view([12040]); lightinggouraud; camlight; 56|Tocreateamoredefinitiveimageoftheneuralactivityatparticularpositions,generatetwo-dimensionalslicesthroughthethree-dimensionalrepresentations.Thiscombinationprovidesthemostcompleteandintegratedrepresentationofneuralandanatomicaldata(Fig.7). cfg.slice='2d'; ft_sourceplot(cfg,freq_sel2,mesh_rha);

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 26: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

TIMINGSteps2-5,PreprocessingoftheanatomicalMRI:~2minSteps6-8,CorticalsurfaceextractionwithFreeSurfer(optional):~10hrsSteps9-12,PreprocessingoftheanatomicalCT:~2minSteps13-15,FusionoftheCTwiththeMRI:~3minSteps16-19,Electrodeplacement:~15minSteps21-24,Brainshiftcompensation(optional):~5minSteps25-28,Volume-basedregistration(optional):~2minSteps29-31,Surface-basedregistration(optional):~2minSteps32-33,Anatomicallabeling(optional):~1minSteps34-43,Preprocessingoftheneuralrecordings:~10minSteps44-45,Time-frequencyanalysis(optional):~2minSteps46-48,Interactiveplotting:~3minSteps49-51,ECoGdatarepresentation:~1minSteps52-56,SEEGdatarepresentation:~2minBox2,Coordinatesystemdetermination:~1min

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 27: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

ANTICIPATEDRESULTSUponcompletionoftheprotocol,oneshouldobtainanintegratedrepresentationofneuralandanatomicaldata.Theexactresultsdependultimatelyontheclinicalorresearchquestionathand,contingenciesintheexperimentalparadigm,anddecisionsmadeduringtheexecutionoftheprotocol.Wedemonstratedtheanalysisofspatiotemporalneuraldynamicsoccurringinrelationtoknownexperimentalstructureandrelativelysimplebehavior,namelythepressingofabuttonwiththerighthandwhenhearingatargettone(Fig.5-7,SupplementaryVideo6).However,withsmalladaptationsoftheprotocolitisfeasibletotrackthespatiotemporalevolutionofepileptiformactivitywithhighprecision(SupplementaryVideo7),ortoperformgroup-levelinvestigationsoffine-graineddecision-relatedneuraldynamicsinhumanorbitofrontalcortex48.Aprecisefusionoftheanatomicalimageswiththeelectrophysiologicaldataiskeytoreproducibleanalysesandfindings.Hence,itisimportanttoexaminetheoutcomeofanycriticalstep,aswehavedoneinthisprotocol(e.g.,Fig.3and4).

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 28: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

AcknowledgmentsTheauthorsthankthepatientforparticipationandChristopherR.Holdgraf,VinithaRangarajan,ColinW.Hoy,JuliaKam,LudovicBellier,RandolphHelfrich,RichardJimenez,EddenGerber,AlejandroBlenkmann,JamieLubell,andMichaelPereiraforfruitfuldiscussions.TheauthorsarealsogratefultothepresentandformerFieldTripcoredevelopersaswellasthegreaterFieldTripcommunityforcontributingcode,documentationandexpertisethathavemadethisprotocolpossible.A.S.wassupportedbyRubicongrant#446-14-007fromNWOandMarieSklodowska-CurieGlobalFellowship#658868fromtheEuropeanUnion;R.vd.M.byR01#MH095984-03S1fromNIMH;J-M.S.byVIDI#864-14-011fromNWO,R.T.K.byNINDSR37NS21135,andR.O.byH2020-MSCA-ITN-2014fromtheECMarieCurieActions.AuthorcontributionsA.S.,S.M.G,R.v.d.M.,J-M.S.,andR.O.developedtheprotocol.G.P.contributedthealgorithmforbrainshiftcompensation.J.J.L. providedaccessandguidanceinthedataacquisition.A.S.,S.M.G,J-M.S.,R.T.K,andR.O.wrotethepaper,andallotherauthorsprovidedsubstantialeditorialrevisions.CompetingfinancialinterestsTheauthorsdeclarethattheyhavenocompetingfinancialinterests.

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 29: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

References1. Buzsaki,G.,Anastassiou,C.A.&Koch,C.Theoriginofextracellularfieldsand

currents--EEG,ECoG,LFPandspikes.NatRevNeurosci13,407–420(2012).2. Malmivuo,J.&Plonsey,R.Bioelectromagnetism:PrinciplesandApplicationsof

BioelectricandBiomagneticFields.Bioelectromagnetism:PrinciplesandApplicationsofBioelectricandBiomagneticFields(2012).doi:10.1093/acprof:oso/9780195058239.001.0001

3. Brunner,P.etal.Apracticalprocedureforreal-timefunctionalmappingofeloquentcortexusingelectrocorticographicsignalsinhumans.EpilepsyBehav.15,278–286(2009).

4. Ritaccio,A.etal.ProceedingsoftheFifthInternationalWorkshoponAdvancesinElectrocorticography.EpilepsyBehav.E&B;41,183–92(2014).

5. Lachaux,J.-P.,Axmacher,N.,Mormann,F.,Halgren,E.&Crone,N.E.High-frequencyneuralactivityandhumancognition:Past,presentandpossiblefutureofintracranialEEGresearch.Prog.Neurobiol.98,279–301(2012).

6. Friston,J.A.andK.&Wellcome.MultimodalImageCoregistrationandPartitioning-aUnifiedFramework.Neuroimage6,209–217(1997).

7. Jenkinson,M.,Bannister,P.,Brady,M.&Smith,S.Improvedoptimizationfortherobustandaccuratelinearregistrationandmotioncorrectionofbrainimages.Neuroimage17,825–841(2002).

8. Cox,R.W.AFNI:softwareforanalysisandvisualizationoffunctionalmagneticresonanceneuroimages.Comput.Biomed.Res.29,162–73(1996).

9. Papademetris,X.etal.BioImageSuite:Anintegratedmedicalimageanalysissuite:Anupdate.InsightJ.2006,209(2006).

10. Azarion,A.A.etal.Anopen-sourceautomatedplatformforthree-dimensionalvisualizationofsubduralelectrodesusingCT-MRIcoregistration.Epilepsia55,2028–2037(2014).

11. Blenkmann,A.O.etal.iElectrodes:AComprehensiveOpen-SourceToolboxforDepthandSubduralGridElectrodeLocalization.Front.Neuroinform.11,14(2017).

12. Groppe,D.M.etal.iELVis:AnopensourceMATLABtoolboxforlocalizingandvisualizinghumanintracranialelectrodedata.J.Neurosci.Methods281,40–48(2017).

13. Kubanek,J.&Schalk,G.NeuralAct:ATooltoVisualizeElectrocortical(ECoG)ActivityonaThree-DimensionalModeloftheCortex.Neuroinformatics13,167–174(2015).

14. Branco,M.P.etal.ALICE:AtoolforAutomaticLocalizationofIntra-CranialElectrodesforclinicalandhigh-densitygrids.Prep.

15. Qin,C.etal.AutomaticandPreciseLocalizationandCorticalLabelingofSubduralandDepthIntracranialElectrodes.Front.Neuroinform.11,1–10(2017).

16. Hill,N.J.etal.RecordingHumanElectrocorticographic(ECoG)SignalsforNeuroscientificResearchandReal-timeFunctionalCorticalMapping.J.Vis.Exp.(2012).doi:10.3791/3993

17. Eglen,S.J.etal.Towardstandardpracticesforsharingcomputercodeandprogramsinneuroscience.Nat.Neurosci.20,770–773(2017).

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 30: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

18. Delorme,A.&Makeig,S.EEGLAB:Anopensourcetoolboxforanalysisofsingle-trialEEGdynamicsincludingindependentcomponentanalysis.J.Neurosci.Methods134,9–21(2004).

19. Zheng,J.etal.Amygdala-hippocampaldynamicsduringsalientinformationprocessing.Nat.Commun.8,14413(2017).

20. Tang,C.,Hamilton,L.S.&Chang,E.F.Intonationalspeechprosodyencodinginthehumanauditorycortex.Science(80-.).357,(2017).

21. Martinet,L.-E.etal.Humanseizurescoupleacrossspatialscalesthroughtravellingwavedynamics.Nat.Commun.8,14896(2017).

22. Gelinas,J.N.,Khodagholy,D.,Thesen,T.,Devinsky,O.&Buzsáki,G.Interictalepileptiformdischargesinducehippocampal–corticalcouplingintemporallobeepilepsy.Nat.Med.22,641–648(2016).

23. Hermes,D.,Miller,K.J.,Noordmans,H.J.,Vansteensel,M.J.&Ramsey,N.F.Automatedelectrocorticographicelectrodelocalizationonindividuallyrenderedbrainsurfaces.J.Neurosci.Methods185,293–298(2010).

24. Dalal,S.S.etal.Localizationofneurosurgicallyimplantedelectrodesviaphotograph-MRI-radiographcoregistration.J.Neurosci.Methods174,106–115(2008).

25. Yang,A.I.etal.Localizationofdenseintracranialelectrodearraysusingmagneticresonanceimaging.Neuroimage63,157–165(2012).

26. Onofrey,J.A.,Staib,L.H.&Papademetris,X.Learningintervention-induceddeformationsfornon-rigidMR-CTregistrationandelectrodelocalizationinepilepsypatients.NeuroImageClin.10,291–301(2016).

27. Pieters,T.A.,Conner,C.R.&Tandon,N.Recursivegridpartitioningonacorticalsurfacemodel:anoptimizedtechniqueforthelocalizationofimplantedsubduralelectrodes.J.Neurosurg.118,1086–1097(2013).

28. Stieglitz,L.H.etal.Improvedlocalizationofimplantedsubduralelectrodecontactsonmagneticresonanceimagingwithanelasticimagefusionalgorithminaninvasiveelectroencephalographyrecording.Clin.Neurosurg.10,506–513(2014).

29. Brang,D.,Dai,Z.,Zheng,W.&Towle,V.L.RegisteringimagedECoGelectrodestohumancortex:Ageometry-basedtechnique.J.Neurosci.Methods273,64–73(2016).

30. Dykstra,A.R.etal.Individualizedlocalizationandcorticalsurface-basedregistrationofintracranialelectrodes.Neuroimage59,3563–3570(2012).

31. Khodagholy,D.etal.Organicelectronicsforhigh-resolutionelectrocorticographyofthehumanbrain.Sci.Adv.2,1–9(2016).

32. Seo,D.etal.WirelessRecordinginthePeripheralNervousSystemwithUltrasonicNeuralDust.Neuron91,529–539(2016).

33. Lauro,P.M.etal.DBSproc:AnopensourceprocessforDBSelectrodelocalizationandtractographicanalysis.Hum.BrainMapp.37,422–433(2016).

34. Horn,A.&Kühn,A.A.Lead-DBS:Atoolboxfordeepbrainstimulationelectrodelocalizationsandvisualizations.Neuroimage107,127–135(2015).

35. Dale,A.M.,Fischl,B.&Sereno,M.I.CorticalSurface-BasedAnalysis:I.SegmentationandSurfaceReconstruction.Neuroimage9,179–194(1999).

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 31: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

36. Lepore,N.etal.ANewCombinedSurfaceandVolumeRegistration.Med.Imaging2010ImageProcess.7623,(2010).

37. Klein,A.etal.Evaluationofvolume-basedandsurface-basedbrainimageregistrationmethods.Neuroimage51,214–220(2010).

38. Hill,D.L.G.etal.Measurementofintraoperativebrainsurfacedeformationunderacraniotomy.Neurosurgery43,514–526(1998).

39. Roberts,D.W.,Hartov,A.,Kennedy,F.E.,Miga,M.I.&Paulsen,K.D.Intraoperativebrainshiftanddeformation:Aquantitativeanalysisofcorticaldisplacementin28cases.Neurosurgery43,749–758(1998).

40. Miyagi,Y.,Shima,F.&Sasaki,T.Brainshift:anerrorfactorduringimplantationofdeepbrainstimulationelectrodes.J.Neurosurg.107,989–97(2007).

41. Hastreiter,P.etal.Strategiesforbrainshiftevaluation.Med.ImageAnal.8,447–464(2004).

42. LaViolette,P.S.etal.Three-dimensionalvisualizationofsubduralelectrodesforpresurgicalplanning.Neurosurgery68,(2011).

43. Sweet,J.A.,Hdeib,A.M.,Sloan,A.&Miller,J.P.Depthsandgridsinbraintumors:Implantationstrategies,techniques,andcomplications.Epilepsia54,66–71(2013).

44. Kovalev,D.etal.Rapidandfullyautomatedvisualizationofsubduralelectrodesinthepresurgicalevaluationofepilepsypatients.Am.J.Neuroradiol.26,1078–1083(2005).

45. Wang,P.T.etal.Aco-registrationapproachforelectrocorticogramelectrodelocalizationusingpost-implantationMRIandCTofthehead.inInternationalIEEE/EMBSConferenceonNeuralEngineering,NER525–528(2013).doi:10.1109/NER.2013.6695987

46. Schulze-Bonhage,A.H.J.etal.Visualizationofsubduralstripandgridelectrodesusingcurvilinearreformattingof3DMRimagingdatasets.Am.J.Neuroradiol.23,400–403(2002).

47. Boatman-Reich,D.etal.Quantifyingauditoryevent-relatedresponsesinmultichannelhumanintracranialrecordings.Front.Comput.Neurosci.4,4(2010).

48. Saez,I.etal.DissociablerolesfortransientandsustainedresponsesinhumanOFCduringdecision-making.UnderRev.

49. Manning,J.R.,Jacobs,J.,Fried,I.&Kahana,M.J.Broadbandshiftsinlocalfieldpotentialpowerspectraarecorrelatedwithsingle-neuronspikinginhumans.JNeurosci29,13613–13620(2009).

50. Miller,K.J.Broadbandspectralchange:evidenceforamacroscalecorrelateofpopulationfiringrate?J.Neurosci.30,6477–6479(2010).

51. Ray,S.&Maunsell,J.H.R.Differentoriginsofgammarhythmandhigh-gammaactivityinmacaquevisualcortex.PLoSBiol.9,(2011).

52. Crone,N.E.,Miglioretti,D.L.,Gordon,B.,Lesser,R.P.&Crone,N.FunctionalmappingofhumansensorimotorcortexwithelectrocorticographicspectralanalysisII.Event-relatedsynchronizationinthegammaband.Brain121,2301–2315(1998).

53. Oostenveld,R.,Fries,P.,Maris,E.&Schoffelen,J.M.FieldTrip:Opensource

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 32: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

softwareforadvancedanalysisofMEG,EEG,andinvasiveelectrophysiologicaldata.Comput.Intell.Neurosci.2011,(2011).

54. Maris,E.&Oostenveld,R.NonparametricstatisticaltestingofEEG-andMEG-data.J.Neurosci.Methods164,177–190(2007).

55. Bastos,A.M.&Schoffelen,J.-M.ATutorialReviewofFunctionalConnectivityAnalysisMethodsandTheirInterpretationalPitfalls.Front.Syst.Neurosci.9,1–23(2016).

56. Drury,H.A.,VanEssen,D.C.,Corbetta,M.&Snyder,A.Z.inBrainWarping337–363(1999).

57. Wells,W.M.,Viola,P.,Atsumi,H.,Nakajima,S.&Kikinis,R.Multi-modalvolumeregistrationbymaximizationofmutualinformation.Med.ImageAnal.1,35–51(1996).

58. Collignon,A.&Maes,F.Automatedmulti-modalityimageregistrationbasedoninformationtheory.Proc.Inf.Process.Med.Imaging263–274(1995).

59. Schaer,M.etal.ASurface-basedapproachtoquantifylocalcorticalgyrification.IEEETrans.Med.Imaging27,161–170(2008).

60. Ashburner,J.&Friston,K.J.Nonlinearspatialnormalizationusingbasisfunctions.Hum.BrainMapp.7,254–266(1999).

61. Lancaster,J.L.etal.Automatedlabelingofthehumanbrain:Apreliminaryreportonthedevelopmentandevaluationofaforward-transformmethod.inHumanBrainMapping5,238–242(1997).

62. Tzourio-Mazoyer,N.etal.AutomatedanatomicallabelingofactivationsinSPMusingamacroscopicanatomicalparcellationoftheMNIMRIsingle-subjectbrain.Neuroimage15,273–289(2002).

63. Cocosco,C.a,Kollokian,V.,Kwan,R.K.,Pike,G.B.&Evans,A.C.BrainWeb :OnlineInterfacetoa3DMRISimulatedBrainDatabase.3-rdInt.Conf.Funct.Mapp.Hum.Brain1131,1996(1996).

64. Eickhoff,S.B.etal.AnewSPMtoolboxforcombiningprobabilisticcytoarchitectonicmapsandfunctionalimagingdata.Neuroimage25,1325–1335(2005).

65. Wang,L.,Mruczek,R.E.B.,Arcaro,M.J.&Kastner,S.Probabilisticmapsofvisualtopographyinhumancortex.Cereb.Cortex25,3911–3931(2015).

66. Fan,L.etal.TheHumanBrainnetomeAtlas:ANewBrainAtlasBasedonConnectionalArchitecture.Cereb.Cortex26,3508–3526(2016).

67. Desikan,R.S.etal.AnautomatedlabelingsystemforsubdividingthehumancerebralcortexonMRIscansintogyralbasedregionsofinterest.Neuroimage31,968–980(2006).

68. Destrieux,C.,Fischl,B.,Dale,A.&Halgren,E.Automaticparcellationofhumancorticalgyriandsulciusingstandardanatomicalnomenclature.Neuroimage53,1–15(2010).

69. Bigdely-Shamlo,N.,Mullen,T.,Kothe,C.,Su,K.-M.&Robbins,K.A.ThePREPpipeline:standardizedpreprocessingforlarge-scaleEEGanalysis.Front.Neuroinform.9,16(2015).

70. Liu,Y.,Coon,W.G.,Pesters,A.de,Brunner,P.&Schalk,G.Theeffectsofspatialfilteringandartifactsonelectrocorticographicsignals.J.NeuralEng.12,56008(2015).

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 33: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

71. Dien,J.Issuesintheapplicationoftheaveragereference:Review,critiques,andrecommendations.Behav.Res.Methods,Instruments,Comput.30,34–43(1998).

72. Ludwig,K.A.etal.Usingacommonaveragereferencetoimprovecorticalneuronrecordingsfrommicroelectrodearrays.J.Neurophysiol.101,1679–1689(2009).

73. Trongnetrpunya,A.etal.AssessingGrangerCausalityinElectrophysiologicalData:RemovingtheAdverseEffectsofCommonSignalsviaBipolarDerivations.Front.Syst.Neurosci.9,189(2015).

74. Shirhatti,V.,Borthakur,A.&Ray,S.EffectofReferenceSchemeonPowerandPhaseoftheLocalFieldPotential.NeuralComput.882–913(2016).doi:10.1162/NECO

75. Arnulfo,G.,Hirvonen,J.,Nobili,L.,Palva,S.&Palva,J.M.Phaseandamplitudecorrelationsinresting-stateactivityinhumanstereotacticalEEGrecordings.Neuroimage112,114–127(2015).

76. Zaveri,H.P.,Duckrow,R.B.&Spencer,S.S.Ontheuseofbipolarmontagesfortime-seriesanalysisofintracranialelectroencephalograms.Clin.Neurophysiol.117,2102–2108(2006).

77. Mercier,M.R.etal.EvaluationofcorticalLocalFieldPotentialdiffusioninStereotacticElectro-EncephaloGraphyrecordings:aglimpseonwhitemattersignal.Neuroimage(2016).doi:10.1016/j.neuroimage.2016.08.037

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 34: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

TABLE1|Troubleshootingtable.Step Problem Possiblereason Solution7 Unsatisfactory

qualityofcorticalsurfaces

InsufficientqualityoftheMRI

Repeatstep6onanotherMRIormanuallycorrectthetopologicaldefects(seeFreeSurferwebsite)

14 SeveremisalignmentofCTandMRI

FailureoftheautomaticCTconversioninstep12

DirectlyaligntotheACPCsysteminstep11byvirtueofeducatedguessesofthecommissurelocations

ImperfectalignmentofCTandMRI

Aleft-rightflipofeitherMRIorCT

Re-examinethenativeorientationsoftheMRIandCTinsteps3and10,andredothepreprocessingoftheaffectedscan

ImperfectalignmentofCTandMRI

MRIandCTcontaindifferentheadanatomies

Repeatstep13withadifferentcostfunction(typehelpft_volumerealign)

17 Electrodeshardtoidentifyinthe2Dorthoplot

Corticalgridorientationnotalignedwithanyofthe2Dplanes

Identifyelectrodesinthe3Dscatterfigure(tickthescattercheckbox)

23 Severedeformationoftheelectrodegrid

Incorrectpairingofneighboringelectrodesinspace

Repeatstep22withalternatesettings(typehelpft_electroderealign)

27 Unsatisfactoryqualityofthevolume-basedregistration

InsufficientqualityoftheMRI

Repeatstep25withanalternatecostfunctionortemplateversion(typehelpft_volumenormalise)

33 Noanatomicallabelfound

Nooverlapofelectrodepositionwithanyanatomicalmask

Increasethesearchradiusaroundtheelectrodebyincreasingcfg.maxqueryrange(typehelpft_volumelookup)

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 35: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Figure1|Overviewoftheprocedure.Theprotocolisgroundedintwoparallelbutinterrelatedworkflows.Theanatomicalworkflowminimallyconsistsofthepreprocessingandfusionoftheanatomicalimagesandelectrodeplacement.Thefunctionalworkflowencompassesthepreprocessingoftheneuralrecordings,butmayalsoincludefollow-upactivitiessuchasevent-relatedaveraging,time-frequencyandstatisticalanalysis.Theelectrodeplacementactivityofferstheopportunitytodirectlylinkanatomicallocationstoelectrodelabelscorrespondingtotheneuralrecordings,allowingforanearlyseamlessintegrationofthetwoworkflowstofacilitateanatomicallyinformeddataexplorationandvisualization.Figure2|Interactiveelectrodeplacement.ClickinganelectrodelabelinthemainpanelontheleftwilldirectlyassignthatlabeltothecurrentcrosshairpositionintheCTscan.SeveralfeaturesfacilitateprecisenavigationoftheanatomicalCT,suchasazoommode,amagnetoptionthattransportsthecrosshairtothenearestweightedmaximum(orminimumincaseofapost-implantMRI),andtheinteractivethree-dimensionalscatterfigureshownontheright.Figure3|Brainshiftcompensation.Insomepatients,compensationforelectrodedisplacementduetobrainshiftafterimplantationmaybenecessary.Inthisparticularcase,asubduralhygromaatthetopofthebraincausedsevereelectrodedisplacementinadirectionoppositetothemorecommonlyobservedinwardshift(left).Realigningelectrodegridstothecorticalsurfacecancompensateforelectrodedisplacementduetobrainshift(right).Thethinblacklinesindicateeachelectrode’spathfromitslocalizedoriginonthelefttoitsprojectedlocationontheright.Figure4|Spatialnormalization.Ontheleftaretheelectrodesontheindividualcorticalsheet.ThetoprightshowstheelectrodesonthestandardMNIbrainaftervolume-basedregistration.ThebottomrightshowstheelectrodesonFreeSurfer'sfsaveragebrainaftersurface-basedregistration.Comparedtovolume-basedregistration,withsurface-basedregistrationtheoriginalgridgeometryisnolongerpreservedaselectrodesaremovedfromonebraintoanotheraccordingtothecurvaturepatternofthecortex.Figure5|Interactiveplotting.FastbrowsingthroughvariousanatomicallyinformedrepresentationsoftheneuraldatacanhelpaddressthemultidimensionalityofintracranialEEGdata.Figure6|ECoGdatarepresentation.Task-inducedhigh-frequency-bandactivityrelativetoabaselineinterval,plottedonacorticalsurfacemeshofthesubject’sbrain.Figure7|SEEGdatarepresentation.

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 36: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Task-inducedhigh-frequency-bandactivityrelativetoabaselineinterval,plottedaspointcloudsaroundatriangulatedmeshofthesubject’samygdalaandhippocampusintherighthemisphere.Thetwo-dimensionalplanesontherightcorrespondtotheslicesintheimageontheleft.

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 37: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Box1|GettingstartedwithFieldTripAllcodeoftheprotocolisdirectlyintegratedwith,andfreelyavailablethroughFieldTrip53.ThisMATLAB-basedopensourcetoolboxoffersadvancedanalysismethodsforelectrophysiologicaldata,suchasevent-relatedaveraging,frequencyandtime-frequencyanalysis,sourcemodeling(forEEGandMEG),connectivityanalysis,classification,real-timedataprocessing,and(non)parametricstatisticalinference.TheimplementationasatoolboxallowsuserstoperformelaborateandstructuredanalysesoflargedatasetsusingtheMATLABcommandlineandbatchscripting.Tutorialdocumentation,answerstofrequentlyaskedquestions,andexamplecodeareavailableonlineasawiki:http://www.fieldtriptoolbox.org.Thetoolbox’sinfrastructureallowsusersanddeveloperstorelativelyeasilyextendthefunctionalityandimplementnewalgorithms.Overthepastdecade,theFieldTriptoolboxhasgrowntoanestimated5000users.

TogetstartedwithFieldTrip,downloadthemostrecentversionfromitshomepageorGitHub,andsetupyourMATLABpath.

addpath<pathtofieldtriphomedirectory>ft_defaults

FieldTripfunctionalities,recognizablebyanftprefix,typicallyhaveasingleoutputargumentandoneortwoinputarguments,thefirstinputargumentbeingconfigurationstructurecfg.

cfg=[];cfg.hpfilter=‘yes’;

cfg.hpfreq=1;data_filt=ft_preprocessing(cfg,data);

Here,inputdataisprocessedbyft_preprocessingaccordingtoparametersspecifiedinthecfgfields,inthiscaseapplyinga1Hzhigh-passfilter.Eachfunction’soptionalparametersareavailableintherespectivefunction’sheader(typehelpfunctionname)andexamplesaregivenonthewiki. Thecfgstructurethatholdstheparameterstothealgorithmatthepresentlevelisautomaticallyappendedtotheoutputdatastructure,i.e.data_filt.cfg.Configurationstructuresusedatpreviouslevelsarekeptindata_filt.cfg.previous,data_filt.cfg.previous.previous,andsoon.Thisnestingofpreviousconfigurationsallowsforaccesstothefulldataprovenanceatanyleveloftheanalysispipeline(seeft_analysispipelineforvisualizingthepipelineasaflowchart).

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 38: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Box2|Coordinatesystemdetermination,TIMING:~1minCoordinatesystemsdefinetheorientationandunitsoftheX-,Y-,andZ-axesofananatomicalvolumeinadditiontoanoriginpointalongthebrain’smidline(e.g.,anteriorcommissure).HereweprovideaguidelinefordeterminingthenativecoordinatesystemoftheMRIandCTscansand,inparticular,whethertheyhavealeft-to-rightoraright-to-leftorientation.Knowledgeoftheorientationoftheleft-rightaxisofthescan'snativecoordinatesystemprovidesthenecessarycontextfordemarcatingtherighthemispherelandmarkinthesucceedingalignmentstep.Althoughtheinterpretationofposterior-anteriorandinferior-superioraxesisstraightforwardfromaxial,coronal,orsagittalslicesofthebrain,differentiatingleftandrightrequiresathree-dimensionalcontext.Toaccomplishthis,werecommendusingft_determine_coordsys,whichdepictsananatomicalvolumeasthreeintersecting,orthogonalslicesandlabelstheX-,Y-,andZ-axes.Thisallowsdeterminingwhichofthesethreeaxesrepresentstheleft-rightaxisand,importantly,whetherthataxishasaleft-to-rightoraright-to-leftorientation(SupplementaryVideo1).1.VisualizethecoordinatesystemoftheMRIorCT:ft_determine_coordsys(mri)2.Determinewhichofthethreeaxes,X,Y,orZ,runsthroughoralongtheleft-rightaxisofthesubject'shead.Thisaxisistheleft-rightaxisforthisanatomicalvolume.3.Determinetheorientationoftheleft-rightaxis.Ifthevaluesontheleft-rightaxisincreasetotheright(indicatedbya+sign),thenthescanhasaleft-to-Rightorientation.Ifthevaluesontheleft-rightaxisincreasetotheleft,thenthescanhasaright-to-Leftorientation.4.Writedowntheorientationofthescan'sleft-rightaxis.

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 39: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Box3|Re-montagingTherecordedelectrophysiologicalsignalsareamixtureofsignal-of-interestandnoise,bothneuralandnon-neural.Themainobjectiveofthepreprocessingoftheneuralrecordingsistoimprovethesignal-to-noiseratioofthedatawhileoptimallypreparingitforfollow-upanalysis.Re-montagingtoadifferentreferencingscheme,alsoknownasamontage,mayaidintheremovalofnoisethatissharedacrossmultiplechannels.Thecommonaveragere-referencingtechnique,forinstance,involvestakingtheaveragepotentialfromallchannelsandsubtractingthisglobalnoiseestimatefromthepotentialineachchannel47,69–72.Wedemonstratedhowtoapplythistechniquetothecorticalgridelectrodesinourexamplecase. Depthelectrodes,locatedinsidethebrainandusingdifferentlysizedandshapedcontactpoints,haveadifferentsensitivitydistributionandcapturedifferenttypesofactivityandlevelsofnoise2.Thereiscurrentlynoconsensusonthepreferredmontagefordepth-electroderecordingsand,thus,whatelectrodestouseasreferences73–76.Whitemattersignalsmaynotbeassilentasonewouldintuitivelyexpect,andbipolarsignals,despitebeingrelativelyclean,missoutonactivitythathadthesameamplitudeonthetwoconsecutiveelectrodespriortotheircombination5,77.Differentoptionsmayneedtobetestedandevaluatedpercase,takingintoaccountthepurposeofanyfollow-upanalysis71.Forinstance,see55foradiscussionofconnectivityanalysisinrelationtothereferencingscheme.

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 40: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

SupplementaryinformationSupplementaryFile1.Start-to-endimplementationoftheanatomicalandfunctional

workflows,SubjectUCI29.mSupplementaryFile2.AutomaticDICOMseriessearchandvisualizationtool,

search_dicomseries.mSupplementaryFile3.Automaticelectrodelabelingtool,generate_electable.mSupplementaryVideo1.PreprocessingoftheanatomicalMRIpart1SupplementaryVideo2.PreprocessingoftheanatomicalMRIpart2SupplementaryVideo3.PreprocessingoftheanatomicalCTSupplementaryVideo4.ElectrodeplacementSupplementaryVideo5.InteractiveplottingSupplementaryVideo6.Spatiotemporaldynamicsoftask-modulatedhigh-

frequency-bandactivityatsurfaceelectrodesoverlaidonleftparietalandtemporalcortex.Itcanbeobservedthatprocessingoccursinthetemporallobeathearingthetargettonefollowedbythesensorimotorsystemcontralateraltothehandusedforthebuttonpress.Warmandcoldcolorsrepresentincreasesanddecreasesinhigh-frequency-bandpower,respectively.

SupplementaryVideo7.Spatiotemporaldynamicsofepileptiformactivityrecorded

fromdepthelectrodestargetingbilateralhippocampusandamygdala.Itcanbeobservedthatthe(interictal)epileptiformdischargesfirstoccurinthelefthippocampusandamygdalaandthenspreadtotheirrighthemispherehomologuesduringthisparticularepisode.Warmandcoldcolorsrepresentpositiveandnegativedeflectionsinsignalamplitude,respectively.Thesizeofthepointcloudsindicatesthesignal'samplitude.

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

arjen stolk
https://youtu.be/KvmilLY9MiE
arjen stolk
https://youtu.be/K9rwGWr-ZnA
arjen stolk
https://youtu.be/0r-0mFWCSWI
arjen stolk
https://youtu.be/31aUH711GUk
arjen stolk
https://youtu.be/k7tvP87bnN4
arjen stolk
https://youtu.be/PTpIve6yiBM
arjen stolk
https://youtu.be/7YYumAjLFik
Page 41: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Preprocessing ofthe anatomical CT

(~2 mins)

Preprocessing ofthe anatomical MRI

(~2 mins)

AN

ATOM

ICA

L WO

RK

FLOW

FUN

CTIO

NA

L WO

RK

FLOW

Electrode placement(~20 mins)

Preprocessing ofthe neural recordings

Time-frequencyanalysis

Statistical analysis

FreeSurfer(optional, ~10 hours,

automatic)

time

chan

nels

time

frequ

enci

es

time

t-sta

tistic

N

LR

R P A

ZZ

Fusion of the CT withthe MRI

(~3 mins, automatic)

VISUALIZATION

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 42: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 43: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Brain shiftcompensation

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 44: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

Volume-basedregistration

Surface-basedregistration

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 45: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 46: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

50%-50%

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 47: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

50%-50%

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 48: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Start-to-end MATLAB implementation of the protocol%% Appendix S1 of Stolk, Griffin et al., Integrated analysis of% anatomical and electrophysiological human intracranial data%% data available at: ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/ ...% tutorial/SubjectUCI29.zip%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

subjID = 'SubjectUCI29';

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% preprocessing of the anatomical MRI%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%mri = ft_read_mri([subjID '_MR_acpc.nii']); % we used the dcm series

ft_determine_coordsys(mri);

cfg = [];cfg.method = 'interactive';cfg.coordsys = 'acpc';mri_acpc = ft_volumerealign(cfg, mri);

cfg = [];cfg.filename = [subjID '_MR_acpc'];cfg.filetype = 'nifti';cfg.parameter = 'anatomy';ft_volumewrite(cfg, mri_acpc);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FreeSurfer%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%fshome = '/Applications/freesurfer';subdir = pwd; % present working directorymrfile = [subdir filesep subjID '_MR_acpc.nii'];system(['export FREESURFER_HOME=' fshome '; ' ... 'source $FREESURFER_HOME/SetUpFreeSurfer.sh; ' ... 'mri_convert -c -oc 0 0 0 ' mrfile ' ' [subdir '/tmp.nii'] '; ' ... 'recon-all -i ' [subdir '/tmp.nii'] ' -s ' 'freesurfer' ' -sd ' ... subdir ' -all'])

fsmri_acpc = ft_read_mri('freesurfer/mri/T1.mgz');fsmri_acpc.coordsys = 'acpc';

pial_lh = ft_read_headshape('freesurfer/surf/lh.pial');pial_lh.coordsys = 'acpc';

ft_plot_mesh(pial_lh);material dull; lighting gouraud; camlight;

1

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 49: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% preprocessing of the anatomical CT%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ct = ft_read_mri([subjID '_CT_acpc_f.nii']); % we used the dcm series

cfg = [];cfg.method = 'interactive';cfg.coordsys = 'ctf';ct_ctf = ft_volumerealign(cfg, ct);

ct_acpc = ft_convert_coordsys(ct_ctf, 'acpc');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fusion of the CT with the MRI%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%cfg = [];cfg.method = 'spm';cfg.spmversion = 'spm12';cfg.coordsys = 'acpc';cfg.viewresult = 'yes';ct_acpc_f = ft_volumerealign(cfg, ct_acpc, fsmri_acpc);

cfg = [];cfg.filename = [subjID '_CT_acpc_f'];cfg.filetype = 'nifti';cfg.parameter = 'anatomy';ft_volumewrite(cfg, ct_acpc_f);

print([subjID '_CT_acpc_f.png'], '-dpng');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% electrode placement%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%load([subjID '_hdr.mat']); % we used ft_read_header

cfg = [];cfg.channel = hdr.label;elec_acpc_f = ft_electrodeplacement(cfg, ct_acpc_f, fsmri_acpc);

save([subjID '_elec_acpc_f.mat'], 'elec_acpc_f');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% brain shift compensation%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%cfg = [];cfg.method = 'cortexhull';cfg.headshape = 'freesurfer/surf/lh.pial';cfg.fshome = '/Applications/freesurfer';hull_lh = ft_prepare_mesh(cfg);

save([subjID '_hull_lh.mat'], 'mesh');

elec_acpc_fr = elec_acpc_f;grids = {'LPG*', 'LTG*'};

2

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 50: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

for g = 1:numel(grids) cfg = []; cfg.channel = grids{g}; cfg.keepchannel = 'yes'; cfg.elec = elec_acpc_fr; cfg.method = 'headshape'; cfg.headshape = hull_lh; cfg.warp = 'dykstra2012'; cfg.feedback = 'yes'; elec_acpc_fr = ft_electroderealign(cfg);end

ft_plot_mesh(pial_lh);ft_plot_sens(elec_acpc_fr);view([-55 10]); material dull; lighting gouraud; camlight

save([subjID '_elec_acpc_fr.mat'], 'elec_acpc_fr');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% volume-based registration%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%[ftver, ftpath] = ft_version;cfg = [];cfg.nonlinear = 'yes';cfg.spmversion = 'spm12';fsmri_mni = ft_volumenormalise(cfg, fsmri_acpc);

elec_mni_frv = elec_acpc_fr;elec_mni_frv.elecpos = ft_warp_apply(fsmri_mni.params, ... elec_acpc_fr.elecpos, 'individual2sn');elec_mni_frv.chanpos = ft_warp_apply(fsmri_mni.params, ... elec_acpc_fr.chanpos, 'individual2sn');elec_mni_frv.coordsys = 'mni';

save([subjID '_elec_mni_frv.mat'], 'elec_mni_frv');

load([ftpath filesep 'template/anatomy/surface_pial_left.mat']);ft_plot_mesh(mesh);ft_plot_sens(elec_mni_frv);view([-90 20]); material dull; lighting gouraud; camlight;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% surface-based registration%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%cfg = [];cfg.channel = {'LPG*', 'LTG*'};cfg.elec = elec_acpc_fr;cfg.method = 'headshape';cfg.headshape = 'freesurfer/surf/lh.pial';cfg.warp = 'fsaverage';cfg.fshome = '/Applications/freesurfer';elec_fsavg_frs = ft_electroderealign(cfg);

save([subjID '_elec_fsavg_frs.mat'], 'elec_fsavg_frs');

3

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 51: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

fspial_lh = ft_read_headshape( ... '/Applications/freesurfer/subjects/fsaverage/surf/lh.pial');fspial_lh.coordsys = 'fsaverage';ft_plot_mesh(fspial_lh);ft_plot_sens(elec_fsavg_frs);view([-90 20]); material dull; lighting gouraud; camlight;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% anatomical labeling%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%atlas = ft_read_atlas([ftpath filesep ... 'template/atlas/aal/ROI_MNI_V4.nii']);

cfg = [];cfg.roi = elec_mni_frv.chanpos( ... match_str(elec_mni_frv.label, 'LHH2'),:);cfg.atlas = atlas;cfg.inputcoord = 'mni';cfg.output = 'label';labels = ft_volumelookup(cfg, atlas);

[~, indx] = max(labels.count);labels.name(indx)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% data inspection and artifact rejection%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%load([subjID '_data.mat'], 'data'); % we used ft_preprocessing

cfg = [];cfg.viewmode = 'vertical';cfg = ft_databrowser(cfg, data);

data = ft_rejectartifact(cfg, data);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% re-referencing%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%cfg = [];cfg.channel = {'LPG*', 'LTG*'};cfg.reref = 'yes';cfg.refchannel = 'all';reref_grids = ft_preprocessing(cfg, data);

depths = {'RAM*', 'RHH*', 'RTH*', 'ROC*', 'LAM*', 'LHH*', 'LTH*'};for d = 1:numel(depths) cfg = []; cfg.channel = ft_channelselection(depths{d}, data.label); cfg.montage.labelold = cfg.channel; cfg.montage.labelnew = strcat(cfg.channel(1:end-1),'-', ... cfg.channel(2:end)); cfg.montage.tra = ... [1 -1 0 0 0 0 0 0

4

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 52: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

0 1 -1 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 1 -1]; cfg.updatesens = 'yes'; reref_depths{d} = ft_preprocessing(cfg, data);end

cfg = [];cfg.appendsens = 'yes';reref = ft_appenddata(cfg, reref_grids, reref_depths{:});

save([subjID '_reref.mat'], 'reref');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% time-frequency analysis%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%cfg = [];cfg.method = 'mtmconvol';cfg.foi = 5:5:200;cfg.toi = -.3:0.01:.8;cfg.t_ftimwin = ones(length(cfg.foi),1).*0.2;cfg.taper = 'hanning';cfg.output = 'pow';freq = ft_freqanalysis(cfg, reref);

save([subjID '_freq.mat'], 'freq');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% interactive plotting%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%cfg = [];cfg.headshape = pial_lh;cfg.projection = 'orthographic';cfg.channel = {'LPG*', 'LTG*'};cfg.viewpoint = 'left';cfg.mask = 'convex';cfg.boxchannel = {'LTG30', 'LTG31'};lay = ft_prepare_layout(cfg, freq);

cfg = [];cfg.baseline = [-.3 -.1];cfg.baselinetype = 'relchange';freq_blc = ft_freqbaseline(cfg, freq);

cfg = [];cfg.layout = lay;cfg.showoutline = 'yes';ft_multiplotTFR(cfg, freq_blc);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ECoG data representation

5

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 53: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%cfg = [];cfg.frequency = [70 150];cfg.avgoverfreq = 'yes';cfg.latency = [0 0.8];cfg.avgovertime = 'yes';freq_sel = ft_selectdata(cfg, freq_blc);

cfg = [];cfg.funparameter = 'powspctrm';cfg.funcolorlim = [-.5 .5];cfg.method = 'surface';cfg.interpmethod = 'sphere_weighteddistance';cfg.sphereradius = 8;cfg.camlight = 'no';ft_sourceplot(cfg, freq_sel, pial_lh);view([-90 20]); material dull; lighting gouraud; camlight;

ft_plot_sens(elec_acpc_fr);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SEEG data representation%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%atlas = ft_read_atlas('freesurfer/mri/aparc+aseg.mgz');atlas.coordsys = 'acpc';cfg = [];cfg.inputcoord = 'acpc';cfg.atlas = atlas;cfg.roi = {'Right-Hippocampus', 'Right-Amygdala'};mask_rha = ft_volumelookup(cfg, atlas);

seg = keepfields(atlas, {'dim', 'unit','coordsys','transform'});seg.brain = mask_rha;cfg = [];cfg.method = 'iso2mesh';cfg.numvertices = 10000;cfg.radbound = 2;cfg.maxsurf = 0;cfg.tissue = 'brain';cfg.smooth = 3;mesh_rha = ft_prepare_mesh(cfg, seg);

cfg = [];cfg.channel = {'RAM*', 'RTH*', 'RHH*'};freq_sel2 = ft_selectdata(cfg, freq_sel);

cfg = [];cfg.funparameter = 'powspctrm';cfg.funcolorlim = [-.5 .5];cfg.method = 'cloud';cfg.slice = '3d';cfg.nslices = 2;cfg.facealpha = .25;ft_sourceplot(cfg, freq_sel2, mesh_rha);

6

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 54: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

view([120 40]); lighting gouraud; camlight;

cfg.slice = '2d';ft_sourceplot(cfg, freq_sel2, mesh_rha);

Published with MATLAB® R2017b

7

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 55: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

function search_dicomseries(directory)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SEARCH_DICOMSERIES searches and visualizes all DICOM files (.DCM)% in a directory and its subdirectories. This can be instrumental for% selecting the best quality scan for follow-up analysis in case there% are multiple.%% Use as:% search_dicomseries(directory)%% Ensure FieldTrip is correcty added to the MATLAB path:% addpath <path to fieldtrip home directory>% ft_defaults%% This function is part of Stolk, Griffin et al., Integrated analysis% of anatomical and electrophysiological human intracranial data%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

threshold = 50; % minimum number of DICOM files required for plotting

list = dir(directory);for l = 1:numel(list) % list loop

if (strcmp(list(l).name, '.') || strcmp(list(l).name, '..') || ... strcmp(list(l).name, '.DS_Store')) % ignore '.' and '..' cases continue; % skip this 'file' end

full_directory = fullfile(directory, list(l).name); if isequal(list(l).isdir, 1) % recurse down search_dicomseries(full_directory); elseif isequal(list(l).isdir, 0) && numel(list)-2 > threshold % plot try fprintf(['>> plotting ' full_directory ' <<\n']); mri = ft_read_mri(full_directory); ft_sourceplot([], mri); title([full_directory ', ' num2str(numel(list)-2) ' dicoms']); drawnow clear mri catch fprintf(['>> could not plot ' full_directory ' <<\n']); end return; % use only one DICOM from each directory end

end % end of list loop

Published with MATLAB® R2017b

1

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 56: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

function generate_electable(filename, varargin)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GENERATE_ELECTABLE writes an electrode anatomy and annotation table%% Use as:% generate_electable(filename, ...)% where filename has an .xlsx file extension,%% and at least one of the following sets of key-value pairs is% specified:% elec_mni = electrode structure, with positions in MNI space%% elec_nat = electrode structure, with positions in native space% fsdir = string, path to freesurfer directory for the subject% (e.g. 'SubjectUCI29/freesurfer')%% Ensure FieldTrip is correcty added to the MATLAB path:% addpath <path to fieldtrip home directory>% ft_defaults%% On Mac and Linux, the freely available xlwrite plugin is needed,% hosted at: http://www.mathworks.com/matlabcentral/fileexchange/38591% xldir = string, path to xlwrite dir (e.g. 'MATLAB/xlwrite')%% This function is part of Stolk, Griffin et al., Integrated analysis% of anatomical and electrophysiological human intracranial data%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% get the optional input argumentselec_mni = ft_getopt(varargin, 'elec_mni');elec_nat = ft_getopt(varargin, 'elec_nat');fsdir = ft_getopt(varargin, 'fsdir');xldir = ft_getopt(varargin, 'xldir');

if isunix % on mac and linux % add java-based xlwrite to overcome windows-only xlswrite addpath(xldir); javaaddpath([xldir '/poi_library/poi-3.8-20120326.jar']); javaaddpath([xldir '/poi_library/poi-ooxml-3.8-20120326.jar']); javaaddpath([xldir ... '/poi_library/poi-ooxml-schemas-3.8-20120326.jar']); javaaddpath([xldir '/poi_library/xmlbeans-2.3.0.jar']); javaaddpath([xldir '/poi_library/dom4j-1.6.1.jar']); javaaddpath([xldir '/poi_library/stax-api-1.0.1.jar']);end

% prepare the atlases and elec structureatlas = {};name = {};elec = [];

1

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 57: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

if ~isempty(elec_mni) % mni-based atlases [~, ftpath] = ft_version; atlas{end+1} = ft_read_atlas([ftpath ... '/template/atlas/afni/TTatlas+tlrc.HEAD']); % AFNI name{end+1} = 'AFNI'; atlas{end+1} = ft_read_atlas([ftpath ... '/template/atlas/aal/ROI_MNI_V4.nii']); % AAL name{end+1} = 'AAL'; brainweb = load([ftpath ... '/template/atlas/brainweb/brainweb_discrete.mat']); atlas{end+1} = brainweb.atlas; clear brainweb; % BrainWeb name{end+1} = 'BrainWeb'; atlas{end+1} = ft_read_atlas([ftpath ... '/template/atlas/spm_anatomy/AllAreas_v18_MPM']); % JuBrain name{end+1} = 'JuBrain'; load([ftpath '/template/atlas/vtpm/vtpm.mat']); atlas{end+1} = vtpm; % VTPM name{end+1} = 'VTPM'; atlas{end+1} = ft_read_atlas([ftpath ... % Brainnetome '/template/atlas/brainnetome/BNA_MPM_thr25_1.25mm.nii']); name{end+1} = 'Brainnetome'; elec = elec_mni;endif ~isempty(elec_nat) && ~isempty(fsdir) % freesurfer-based atlases atlas{end+1} = ft_read_atlas([fsdir ... '/mri/aparc+aseg.mgz']); % Desikan-Killiany (+volumetric) atlas{end}.coordsys = 'mni'; name{end+1} = 'Desikan-Killiany'; atlas{end+1} = ft_read_atlas([fsdir ... '/mri/aparc.a2009s+aseg.mgz']); % Destrieux (+volumetric) atlas{end}.coordsys = 'mni'; name{end+1} = 'Destrieux'; if isempty(elec) % elec_mni not present elec = elec_nat; end elec.elecpos_fs = elec_nat.elecpos;end

% generate the tabletable = {'Electrode','Coordinates','Discard','Epileptic', ... 'Out of Brain','Notes','Loc Meeting',name{:}};for e = 1:numel(elec.label) % electrode loop table{e+1,1} = elec.label{e}; % Electrode table{e+1,2} = num2str(elec.elecpos(e,:)); % Coordinates table{e+1,3} = 0; % Discard table{e+1,4} = 0; % Epileptic table{e+1,5} = 0; % Out of Brain table{e+1,6} = ''; % Notes table{e+1,7} = ''; % Localization Meeting

for a = 1:numel(atlas) % atlas loop fprintf(['>> electrode ' elec.label{e} ', ' table{1,7+a} ... ' atlas <<\n']) cfg = [];

2

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint

Page 58: Integrated analysis of anatomical and electrophysiological ...€¦ · Integrated analysis of anatomical and electrophysiological human intracranial data Arjen Stolk1, Sandon M. Griffin1,

if strcmp(name{a}, 'Desikan-Killiany') || ... strcmp(name{a}, 'Destrieux') % freesurfer-based atlases cfg.roi = elec.elecpos_fs(e,:); % from elec_nat else cfg.roi = elec.elecpos(e,:); % from elec_mni end cfg.atlas = atlas{a}; cfg.inputcoord = 'mni'; cfg.output = 'label'; cfg.maxqueryrange = 5; labels = ft_volumelookup(cfg, atlas{a}); [~, indx] = max(labels.count); table{e+1,7+a} = char(labels.name(indx)); % anatomical label clear labels indx end % end of atlas loopend % end of electrode loop

% write to excel fileif isunix xlwrite(filename, table);else xlswrite(filename, table);end

Published with MATLAB® R2017b

3

.CC-BY-NC 4.0 International licensenot certified by peer review) is the author/funder. It is made available under aThe copyright holder for this preprint (which wasthis version posted December 8, 2017. . https://doi.org/10.1101/230912doi: bioRxiv preprint


Recommended