{'fraction_non_alphanumeric': 0.026029104357613766, 'fraction_numerical': 0.008100176877311465, 'mean_word_length': 4.799393868749272, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Anatomical guidance for functional near-infrared spectroscopy: AtlasViewer tutorial

Abstract. Functional near-infrared spectroscopy (fNIRS) is an optical imaging method that is used to noninvasively measure cerebral hemoglobin concentration changes induced by brain activation. Using structural guidance in fNIRS research enhances interpretation of results and facilitates making comparisons between studies. AtlasViewer is an open-source software package we have developed that incorporates multiple spatial registration tools to enable structural guidance in the interpretation of fNIRS studies. We introduce the reader to the layout of the AtlasViewer graphical user interface, the folder structure, and user files required in the creation of fNIRS probes containing sources and detectors registered to desired locations on the head, evaluating probe fabrication error and intersubject probe placement variability, and different procedures for estimating measurement sensitivity to different brain regions as well as image reconstruction performance. Further, we detail how AtlasViewer provides a generic head atlas for guiding interpretation of fNIRS results, but also permits users to provide subject-specific head anatomies to interpret their results. We anticipate that AtlasViewer will be a valuable tool in improving the anatomical interpretation of fNIRS studies.


Introduction
Functional near-infrared spectroscopy (fNIRS) is an optical imaging method that takes advantage of the low absorption of light by biological tissues in the near-infrared in order to noninvasively measure changes in cerebral hemoglobin concentrations through the intact human scalp and skull. This method has now been used for over 20 years to measure and map brain activation in humans for a broad range of applications, as recently reviewed in a special issue of NeuroImage commemorating 20 years of fNIRS. 1 While fNIRS provides sensitive measures of the changes in the hemoglobin concentrations in the cortex close to the skull, the spatial resolution is limited because the light is strongly scattered by the tissue and must pass through the scalp and skull twice in order to interrogate cerebral hemoglobin concentrations. The spatial resolution of an fNIRS experiment can be roughly approximated by the minimum separation between source and detector optical fibers (or "optodes"). Because the number of optodes is limited, a balance must be found between the density of optodes and coverage over the brain. A separation of 30 mm is typical in adults, but high-density, overlapping measurements with a minimum separation of 13 mm or less have been demonstrated and are becoming more common. 2,3 At this resolution, fNIRS is capable of localizing functional activation to within the width of a cortical gyrus.
In order to interpret fNIRS data and compare results across studies, structural guidance is essential. The simplest way to provide structural guidance is to place the optodes relative to the standardized 10-20 locations on the scalp, which were originally defined for electroencephalography. 4 Jurcak et al. 5 has then related these 10-20 locations on the scalp to the underlying cortical structure and the standard Montreal Neurological Institute (MNI) stereo-tactic coordinates, thus enabling comparison of fNIRS results with locations of brain activation measured with functional magnetic resonance imaging (fMRI) and positron emission tomography (PET). This association of optode locations with the underlying brain anatomy has been addressed extensively by the group of Dr. Dan, as recently reviewed in Ref. 6. Their efforts have provided a robust framework for estimating the underlying brain anatomy that is probed by a given fNIRS measurement. Their procedure essentially provides a probabilistic transformation from the optode locations relative to the scalp 10-20 locations, to the standardized MNI brain coordinate system. 5,6 The power of this approach is that it enables the results of fNIRS studies to be compared with those of fMRI and PET, which are routinely reported using the MNI coordinate system.
Another approach for facilitating anatomical interpretation is to use a head model as an anatomical prior to inform the reconstruction of an image of brain activation using fNIRS data. An example of utilizing MRI data to improve fNIRS analysis can be found in the statistical parameter mapping toolbox NIRS-SPM, which has facilitated cross-modality comparisons in simultaneous fMRI and fNIRS recordings. 7,8 The head model can be derived from a subject-specific anatomy, 9,10 but it has also been shown that accurate images can be produced using a generic anatomical head atlas when the subject's own structure is not available. [11][12][13][14] Anatomically, informed reconstruction allows fNIRS measurements of brain activation to be viewed as images that inherently localize the activation patterns to the structural features of the brain. These images can then be compared across subjects and studies by transforming them into a consistent brain-space, such as that defined by the MNI coordinate system. The advantage of this image reconstruction approach over a channel-based analysis is the potential for improved spatial resolution, particularly when measurements are made with a probe containing a dense array of sources and detectors.
We have developed an open-source software package called AtlasViewer, based on MATLAB ® (The MathWorks Inc., Natick, Massachusetts) scripts, that incorporates these various spatial registration tools to enable fNIRS researchers to easily determine the brain coordinates and sensitivity of their measurements and to easily reconstruct images of their measured brain activation patterns. In this paper, we provide a tutorial to guide the user in the various ways in which AtlasViewer can be used to improve their fNIRS study design and the presentation of their results. Specifically, we introduce the three major functions of AtlasViewer that can aid a user in improving the design and analysis of experimental studies: probe design, evaluation of probe sensitivity and imaging metrics, and the use of subjectspecific head anatomies. We cover each of these functions in the following sections of this tutorial.

AtlasViewer Interface
AtlasViewer is part of the near-infrared spectroscopy software analysis package Homer, 15  To begin, the AtlasViewer graphical user interface (GUI) is depicted in Fig. 1. By default, AtlasViewer will load and display the "Colin27" digital brain atlas that is commonly used in MRI studies. 19 Over time, more atlases will be incorporated into the AtlasViewer distribution, including MNI152 and atlases for infants and children, and users will have access to them through the menu item "File → Change Atlas." For instance, neonatal head models for preterm and term infants have recently been published 20 and integrated into the AtlasViewer distribution. In the lower left of the GUI, controls are provided for displaying the head surface, controlling the opacity of the head, displaying the pial surface, showing the 10-20 reference points on the scalp of the atlas, and displaying the location of reference points and sources and detectors that have been digitized on a specific subject. In the lower-middle section of the GUI, controls are provided for rotating the view of the atlas, zooming, and creating a copy of the figure in a separate window. It is possible to pan the view using the hand tool in the upper-left part of the GUI. In the lower-right of the GUI, there are controls for displaying and manipulating a probe of sources and detectors on the head. The right side of the GUI provides options for calculating and displaying the brain "Sensitivity Profile" of different measurements contained in the probe. Controls are also provided for evaluating and displaying "Image Reconstruction" metrics in order to ascertain the quality of images that can be provided by a given probe of sources and detectors.
AtlasViewer expects a specific folder structure and results for individual subjects are contained in their own subject folders. For example, we consider the root folder for one subject "Subj1." This folder will have subfolders called "fw" and "viewer" that contain files created during various AtlasViewer operations. The user can also specify an "anatomical" folder to provide a subject-specific anatomy for analyses as detailed in Sec. 5.

Probe Design
The majority of fNIRS systems allow source and detector optical fibers to be arranged into a customized probe geometry. The design of such a probe requires the delicate balancing of various factors that impact the quality of the data that will be obtained. These include covering the desired brain regions, maintaining suitable source-detector (SD) separations and maximizing channel density, all with a limited number of sources and detectors. AtlasViewer allows a probe to be designed, amended, and assessed prior to probe fabrication, resulting in accelerated development of an optimal probe.

Sources, Detectors, Measurement Channels, and Springs
To begin creating a new probe design, from the AtlasViewer GUI, click "Tool → Make Probe." This will launch a separate GUI, called SDgui, for creating SD files. If the user does not have a previous probe design to work from, clicking cancel in the "Open SD file" pop-up window will launch SDgui without any preloaded information. If working from a previous design or a work in progress, then navigate to the appropriate *.SD file using this interface or use "File → Open" from the SDgui menu bar. As shown in Fig. 2, SDgui consists of a number of tables to the left-hand side, file and wavelength controls at the bottom and a large graphical representation of the probe in the upper-right (the probe graph). When using SDgui, it is good practice to begin by naming the new probe using the text box at the bottom-center of the GUI. It is also necessary to enter the wavelengths of light that will be used in the experiment, as this is typically determined by hardware choices that have already been made and will not change.
The SDgui has two design views which are toggled using the radio bubble "Add Springs." When the radio bubble is deselected, the user is able to: define the locations of sources and detectors; create measurement channels between sources and detectors; name, save and load files, and assign the wavelengths of light used by their fNIRS system. When "Add Springs" is selected, the source and detector location tables are replaced with tools for creating the springs, dummy optodes, and anchor points that are subsequently used to register a probe onto the surface of the selected atlas. In this example, we will begin by placing a source at (0, 0, 0). To do this, enter a "0" in the first row of the "Sources" scroll box for the columns x, y, and z. This will create a red "1" at location (0, 0, 0) in the graph to the right. Next, add detectors at (30, 0, 0) and (0, 30, 0). These represent placements that are 30 mm to the right of and above the source, respectively. Both millimeters and centimeters can be used in this interface, but when the file is saved the software will ask which units were used and convert them to millimeters, the preferred length unit for AtlasViewer. After the first detector is added, but before the second is entered, the aspect ratio of the graphical representation of the probe may temporarily look strange. This is normal and is a function of the auto scaling that takes place. One source and two detectors are now defined and need to be connected to create measurement channels. In order to do this, click on source number 1 in the probe graph and then on one of the two detectors. A green line will appear between this SD pair. Repeat this for the other SD pair to create the other measurement channel. To remove a channel, repeat the same operation and the channel between the SD pair will be removed. Note that two sources or two detectors cannot be linked together in this way, as a channel cannot be created between two optodes of the same type. This procedure can be used to create the measurement list of all source/detector pairs within a given probe design. The AtlasViewer graphical user interface centers around the display of the selected atlas, with the scalp and cortical surfaces visible. By default, the atlas displayed and utilized by AtlasViewer is based on the high-resolution Colin27 atlas. 19 Within the control panels, there are options to adjust the visible atlas components, the viewing angle and zoom, and probe display. The top menu bar items and the use of the sensitivity profile are detailed in the text.
Next, click the "Add Springs" radio bubble. The probe graph will now contain three optodes with no connections between them and no distinction between sources and detectors. In this phase, the user may connect any optode to any other optode to create a spring. Springs are used to establish the spacing between any two elements in the probe geometry. Add springs between (1, 2), (2, 3), and (3, 1). Clicking on two optodes connected by a spring will remove that spring, just as was the case with the measurement channels. Now create a dummy optode by typing (0; −30; 0) in the "Dummy Optodes" table (left, middle), in row 1, columns x, y, and z. A number will be assigned to the first column and the dummy optode will appear in the probe graph to the right. Create two more dummy optodes at (0, 60, 0) and (60, 0, 0). Use springs to connect dummy optode 4 to optode 1, dummy optode 5 to optode 3, and dummy optode 6 to optode 2. If a spring is clicked, the line will become dashed and the length of the spring in the "Springs" table (left, top) will be set to "−1." This designates that the spring does not have a fixed length, i.e., it is weaker compared to the other springs, and it will behave much more elastically in later steps. In this way, dummy optodes can be utilized with weaker springs to guide probe orientation without constraining distances. Do this for the springs connected to the dummy optodes.
Finally, anchor points are used to fix optodes at specific locations. Add anchor points by entering the following optode-reference point pairs into the "Anchor Points" table: (4, Iz), (5, Pz), and (6, P8). The reference points Iz, Pz, and P8 refer to the standard 10-20 locations on the scalp. When actually selecting these points, it may be helpful to switch back to the AtlasViewer window and activate the "Show Ref Pts" radio bubble, which will display the defined 10-20 reference points that can be used on the atlas head. The SDgui screen should now resemble Fig. 3. A minimum of three anchor points are required to uniquely place the probe onto the surface of the head. In this example, dummy optodes were anchored, but, in general, any source and detector optode can be anchored as well. Care must be taken when choosing the anchor points and springs to ensure that the probe is uniquely and accurately placed onto the surface of the head. Undesirable probe placement results may arise if the plane defined by the anchor points is intersecting the surface of the head near the normal of the surface. It is better for this plane to be closer to the tangent of the head surface. This process of selecting anchor points is quickly learned with some trial and error.
To save the SD file, click the "Save SD File" button in the SD file box. A popup will prompt the user to select which spatial units are being used. Millimeters are recommended and are used in the present example.
Once a probe has been designed, it can be applied in the AtlasViewer GUI. An SD file can be loaded by clicking "Tools → Import Probe," and then selecting the desired SD file. The probe will appear as a set of red numbers above the atlas head volume. Note that if SDgui was launched from within the AtlasViewer GUI, then the SD file information is automatically loaded into AtlasViewer and does not need to be manually imported. In the latter case, the probe is not yet displayed in the AtlasViewer GUI and will not appear until the next step is performed.
Once a probe design is loaded into AtlasViewer, click "Register Probe to Surface" and wait for the process to complete. This may take a few seconds as it runs through a refinement process that finds a minimum energy configuration for the spring geometries after locking the anchor points in place. The spring elements behave like physical springs, using an equal spring constant for all members that have a length greater than zero. Springs with a defined length less than zero (represented by dashed lines in Fig. 3), have a much lower spring constant resulting in a reduced force. With each iteration, the optodes that are not anchored are moved 1 mm toward the surface of the head. Then the spring forces are calculated and the optodes are displaced up to 1 mm based on those forces. This process is repeated until the spring forces reach equilibrium with the optodes in contact with the surface of the head. In this way, the probe is positioned onto the head in a manner that closely approximates the distances specified by the spring connections. Using the rotate/zoom axes buttons allows the atlas head to be rotated and magnified to facilitate viewing the resulting probe registration. By unchecking "Hide Springs" and "Hide Dummy Optodes" in the "Probe" box, while "Hide Meas List" remains checked, it becomes apparent how AtlasViewer positions the optodes on the surface of the head using spring interactions (Fig. 4). In this view, the color of the spring designates the deviation of the spring length in millimeters from the target separation of the two optodes as defined in the SD file. The thresholds for setting the colors are given by the two numbers in the edit box just to the right of the "hide springs" check box. The default values are 3 and 10 mm. The user can set these values by Fig. 3 The SDgui "Add Springs" window allows the user to create spring connections between optodes, create dummy optodes for the sake of positioning or to reinforce the probe geometry, and to anchor optodes to reference points on the head surface.
editing the numbers in the edit box when "Hide Springs" is unchecked. If the absolute value of the deviation is less than the first number then the spring is black. If the absolute value of the deviation is between the first and second numbers then the spring is cyan or yellow for a negative or positive deviation, respectively. Finally, if the absolute value is greater than the second number then the spring is blue or red for a negative or positive deviation, respectively. The interoptode springs in this example should all be black, while the optode-to-dummy optode springs will be red, which is to be expected since their lengths were set to −1, designating them as weaker and thus only used for orientation purposes. If the user desires to have different ranges of accuracy displayed, they can easily edit the thresholds in the edit box.

Example 2: design and registration of an extended probe
Returning to the SDgui, the probe geometry built in example 1 can be extended to cover the majority of the occipital lobe (Fig. 5).
Maintaining the desired optode separations and probe positioning requires the proper application of springs and anchor positioning. A few basic techniques that can be implemented include (1) using crossing springs when a structure should maintain a rigid shape, such as Fig. 6 springs (1, 4) and (13,16), where (m, n) indicates optode #m and optode #n, (2) connecting to anchor points through springs that are in line with support elements or by applying springs symmetrically, such as  The result of registering the example probe to the atlas using the spring relaxation method. The depiction of the probe geometry indicates that the desired spacing was maintained within 3 mm between all source and detector positions (black color coding), while the springs connecting to anchor points are longer than their specified length by more than 10 mm (red color coding). Due to the use of unbalanced anchor points, the probe is positioned slightly to the right of the midline and has rotated slightly clockwise. By choosing different anchor points and/or adding additional anchors and springs, one can make minor adjustments to the probe positioning to get their desired positioning.
springs (9,23) and (12,23), and (3) using fixed length springs to carefully adjust the distance to anchors at nearby reference points, such as Fig. 6 spring (7,25). If a probe design does not correctly register to the surface of the atlas (for example, if it is skewed or rotated), it may be helpful to rebuild the probe incrementally and test the registration after adding each new section. Incorrect registration can typically be resolved by adding additional springs to prevent the relaxation algorithm from finding a local minimum. The user can return to AtlasViewer and "Register Probe to Surface" at any time to visualize the progress of the design.

Projection to the Cortical Surface
Once the probe geometry has been created and is positioned on the atlas head, it should be evaluated to determine if it is successfully targeting the desired brain regions. This can be accomplished in AtlasViewer using the spatial registration tools for fNIRS detailed in Refs. 21 and 22. After a probe has been registered to the surface, clicking the button "Project to cortex" [ Fig. 7(a), bottom-right corner] will draw a vector perpendicular to the surface at the midpoint of each SD pair. The location where each of these vectors meets the cortical surface will then appear in a popup window [ Fig. 7(b)] containing the channel coordinates in the Monte Carlo space, channel position in the standard MNI coordinate space, and a label assignment for the corresponding brain region defined by the "Automated Anatomical Labeling" (AAL) in Ref. 23. The values in this table can be easily copied into your own text file or spread sheet for further analyses. The details of this labeling procedure are provided in Refs. 21 and 22. Knowledge of these standard MNI coordinates and the corresponding cortical label enables the user to compare their results for given channels of data against other fNIRS and fMRI studies reporting results using the same standard MNI coordinates. Also, by clicking the "Labels" radio button under the "Brain Display" panel, the user can visualize the AAL 23 on the surface of the brain in order to visualize the location of each channel with respect to the labeling. The colormap for the anatomical labeling can be changed to a variety of options using the menu item "Tool → Choose Labels Colormap." Note that the Monte Carlo space is defined as a bounding box created around the head volume that has the same orientation as the head surface in the subject space, but has undergone a simple translation to move the entire head volume to the positive octant. This conversion is used in AtlasViewer in order to facilitate performing photon migration using tMCimg, which is covered in Sec. 4. Subject space, Monte Carlo space, and MNI coordinates are all relatable through transformation matrices that are saved as text files in the "anatomical" subject subfolder and are also saved in the AtlasViewer.mat file in the subject root folder. If the brain regions of interest are not adequately covered by the probe design, the probe can be adjusted to better align it with the desired areas. This can be accomplished by modifying the anchor positions, but is often most easily accomplished by adjusting the lengths of the springs that connect to the existing anchor points. If a probe covers the desired areas but does not adequately target subregions within these areas, a denser probe design may be necessary. The advantages of denser probe designs, overlapping channels, and varying SD separations are discussed in greater detail in Sec. 4. Further, the MNI coordinates indicated here provide information about the general location of a given measurement but make no quantitative statement about the sensitivity of the measurement to that location. Sensitivity is quantitatively assessed in Sec. 4.
It is worth noting that all of the work performed in registering the probe and obtaining the cortical projections can be saved at any time with the menu item "File → Save Viewer State." This will save the current state of AtlasViewer in the file atlasViewer.mat in the subject root folder. When AtlasViewer is launched again in this directory, it will read this file and return AtlasViewer to the same state.

Accounting for Variation in Subject Head Size
As head size can vary across subjects, it is important to consider whether or not different head sizes will change the cortical regions sampled by the probe geometry. Above, we described designing a probe and registering it to the surface of an atlas head model. Instead, the atlas can first be registered to a specific head size prior to employing the spring relaxation approach to register the probe design to the surface of the atlas. This allows the user to determine whether changing the head size causes a significant variation in the cortical regions sampled by the probe geometry. The atlas can be registered to a specific head size using the menu item "Tool → Register Atlas to Head Size." This will cause a dialog box to open up and ask for head circumference, distance from nasion (Nz) to inion (Iz), and distance Fig. 6 The probe in Fig. 5 is intended for the occipital cortex and will need to curve around the rear of the head. To accomplish this, anchor points 23 and 24 are connected to the probe by weak springs and draw the top corners of the probe along the sides of the head while anchor point 25 explicitly holds the bottom of the probe at a specified distance from the inion reference point "Iz" using a rigid spring. from left auricular (A1) to right auricular (A2) as measured along the scalp surface of the subject using a tape measure in centimeter units. This tool will then calculate an ellipsoid that matches these dimensions to establish the coordinates of 10-20 reference points Iz, Nz, vertex or central zero (Cz), A1, and A2. The atlas is then registered to these five 10-20 reference points using an affine transformation. This approach can be problematic because of the challenge in accurately measuring the distances and because it assumes an ellipsoid shape for the head.
Alternatively, a more accurate registration of the atlas to the subject can be achieved using a three-dimensional (3-D) digitization system. In this case, the user can import measurements of the coordinates of these five 10-20 reference points on a given subject. AtlasViewer requires these coordinates to be specified in a text file, an example of which is provided with the AtlasViewer package and is shown in Fig. 8. If a correctly formatted text file, named digpts.txt, exists in the root subject folder then the menu item "Tool → Register Atlas to Dig Points" will be available. This function will register the atlas to the five reference points Iz, Nz, Cz, A1, and A2 using an affine transformation. Newer registration approaches have been described in the literature that either relax the need for accurately determining Cz, 21 or utilize additional clouds of points from the scalp surface in order to provide a better registration. We intend to implement these newer approaches in the future and give the user the option of which one to use.

Digitized Optode Positions
If the user has digitized the coordinates of the source and detector optodes and indicated the positions in the digpts.txt file along with the necessary 10-20 reference points (see Fig. 8), then AtlasViewer will display the positions of these sources and detectors on the registered atlas without the user having to Fig. 7 (a) The AtlasViewer graphical user interface provides a number of tools for viewing probe geometries: the cortical surface may be colorized using a variety of color maps to depict different anatomical regions, the head surface may have its opacity adjusted or removed entirely, 10-20 reference points may be toggled on/off, the head may be rotated and zoomed, and various elements of the SD file may be hidden or revealed. (b) The popup window that is created when the "Project to cortex" button is pressed contains the list of SD pairs in the measurement list, the channel coordinates in the Monte Carlo space, the channel coordinates in the Montreal Neurological Institute (MNI) space, and a label for the cortical surface that these MNI coordinates correspond to in the segmented atlas volume. Channel coordinates are given at the midpoint between the associated source and detector. add springs and anchor points to their probe design. After the user has registered the atlas to the 10-20 reference points in digpts.txt using menu item "Tool → Register Atlas to Dig Points," the source and detector optode positions will be visible on the surface of the head. Showing sources and detectors versus optodes is achieved with the "show srcs/dets" check box. AtlasViewer will utilize the imported SD file to obtain the measurement list that defines all pairs of sources and detectors used for measurements. These measurement channels can then be visualized on the head surface by unchecking "Hide Meas List." An additional feature that may be used after importing individual probe geometries into AtlasViewer is the capacity to examine the experimental repeatability of probe position across subjects using "Tool → Probe Placement Variation." This will first prompt the user for the group-level directory folder they would like to analyze, which should contain a subfolder for each subject and each subject folder should have the atlasViewer.mat file created for that subject with the menu item "File → Save Viewer State." The user is then asked to make one of two selections, which will run scripts to analyze either intersubject optode variation or deviation from the optode positions in the original SD file. The first script, "intersubject variability," plots the optode locations for multiple subjects and returns the mean and standard deviation for each optode position (Fig. 9). This is useful for determining how consistently the SD channels are positioned over the targeted cortical areas. The second script, "Probe fabrication error," will run an analysis of how closely the digitized optode locations from individual subjects match the original probe design. In order to accomplish this, the original probe's SD file must be appropriately registered to an atlas surface and saved in an AtlasViewer.mat file by using the menu option "File → Save Viewer State." The file will then need to be renamed "AtlasViewer_SDdesign.mat" and placed in the group directory. In addition to plotting a side-by-side comparison of the original and subject optode locations, it will calculate the mean geometric error for each optode position (Fig. 9) and display the error distribution as projected onto a two-dimensional surface (Fig. 10). This is helpful for evaluating deviations from the original probe design and detecting both single-point and systematic errors in probe fabrication.

Running the Photon Migration Forward Problem
The probabilistic path of photons through a 3-D volume with varying absorption properties can be generated using the freely available Monte-Carlo photon transport software tMCimg, 25 which is included with the distribution of AtlasViewer. AtlasViewer generates the necessary input files for tMCimg when "Forward Model → Generate MC input" is selected and these input files are saved in the "fw" subfolder of the subject root directory. AtlasViewer will then ask if the forward model was executed manually or if tMCimg should be run from within AtlasViewer. It should be possible to have AtlasViewer run tMCimg directly, but the user can instead launch the batch file directly from the "fw" subdirectory. The batch file is called either "fw_all.bat" for Windows or "fw_all.csh" for Mac and Linux. Running tMCimg manually is sometimes desired if the user has access to a cluster of computers and can run tMCimg for different sources and detectors on different computers in parallel to speed up the computation. The input files for tMCimg contain the locations of each source and detector in the probe geometry and the necessary parameters for photon migration. The tMCimg software performs a Monte Carlo random walk to construct a probabilistic model of the path of photons through the medium, and saves the results in the "fw" subfolder. Once tMCimg has been completed for all source and detector positions, the menu item "Forward Model → Generate/Load Sensitivity Profile" is then used to read the tMCimg output in order to generate a forward matrix. The forward matrix represents the spatial sensitivity profile of each measurement channel to cortical absorption changes. Details of how this forward matrix is constructed from the output of the Monte Carlo program can be found in Refs. 11, 12, and 25. While the photon migration problem is solved in the head volume, AtlasViewer projects the volumetric sensitivity in the gray matter onto the surface of the pial matter. This is done by finding the closest surface element for each volume element. For any given surface element, there will be a set of these closest volume elements. Summing over this set of volume Fig. 9 Running the intersubject variability analysis produces the two figures and table above: (a) shows the various probe optode positions color-coded by subject, (b) represents the standard deviation in millimeters, plotted at the mean of the optode positions, and (c) outputs the data presented in the previous two panels as a table that can be copied to the operating system's clipboard. elements gives us the sensitivity for the associated surface element. This assumes that the absorption changes are uniform in the gray matter voxels closest to the pial surface element, and makes it straightforward to visualize sensitivity profiles and imaging metrics on the pial surface. Further, the surface representation of the sensitivity profile requires significantly less memory and disk storage than the volumetric representation. Nonetheless, the user has the option of saving the volumetric sensitivity for offline analysis by enabling the menu item "Forward Model → Enable Sensitivity Matrix Volume." Before generating the tMCimg input files, the user needs to specify the number of photons that will be launched from each optode position. The more photons launched, the more accurate the solution, but the longer the simulation will take. The default value used by AtlasViewer is 1e6, or 1 million photons. This is a relatively small number of photons, but it generates a result quickly; typically less than 1 min/optode. However, to obtain more accurate results, the number of photons should be increased to 1e7 or even 1e8, increasing the length of time for the Monte Carlo simulation by 10 to 100 times, respectively. For rapid assessment of probe placement and sensitivity, 1e6 is likely sufficient. But we recommend the user increase this to 1e7 or 1e8 when the intention is to perform image reconstruction. In future releases, AtlasViewer will support the use of the Monte Carlo program Monte Carlo extreme, which uses the graphical processor unit to speed up the simulation by more than 100×. 26 The user can specify the optical properties (reduced scattering coefficient μ 0 s , and absorption coefficient μ a ) of the different tissue types in the head model. Tissue types can include scalp, skull, cerebral spinal fluid, gray matter, and white matter. While the default atlas (Colin27) has all of these tissue types, it is sufficient that other atlases and user provided anatomies have only two tissue types, brain and extracerebral tissues. In this case, brain would be called gray matter and the extracerebral tissue would be called scalp. If the user does not specify the optical properties, default values are used according to Table 1. The user can adjust the properties by pressing the "Set Opt Prop" button in the "Sensitivity Profile" panel on the right side of the GUI. The menu item "Tool → Calculate Optical Properties" asks the user to specify hemoglobin concentrations, the scattering spectrum of the form μ 0 s ¼ a exp½−bðλ − 800Þ∕800, and the wavelength(s), and then provides the corresponding absorption and scattering properties. By default, the forward model is performed for one set of optical properties, which is sufficient for evaluating the probe performance. In practice, experimental data are usually collected with two or more wavelengths. To perform an image reconstruction analysis of experimental data, it is necessary to define the tissue optical properties for the different wavelengths. To do this, the user just needs to provide N values for each absorption and scattering coefficient that is one value for each of the N wavelengths.

4.2
Using the Spatial Sensitivity Profile, i.e., the Forward Matrix Each row of the photon migration forward matrix represents the sensitivity profile of an individual measurement channel. This enables the user to visually inspect whether or not the probe design is sensitive to specific regions of interest and whether  the aggregate sensitivity of all measurements is sufficiently uniform throughout the areas of interest. The sensitivity profile for a specific SD pair is displayed by entering the source and detector number in the "Channel" edit box. If "0 0" is entered, then the sensitivity profile summed over all channels is displayed. This represents the total sensitivity of the selected probe design. If the probe sensitivity profile does not show sufficient sensitivity to desired locations, increasing the separation between sources and detectors may improve this characteristic, but this will result in further attenuation of the light received by the detectors and, in practice, will increase measurement noise. If the probe is not sufficiently sensitive to the areas of interest, shifting the location of the probe will relocate the areas of higher sensitivity. If more uniform sensitivity is required, changing the probe geometry to provide denser measurements may be necessary.
The sensitivity profile has units of mm −1 . Multiplying the value of the sensitivity profile of a given measurement channel by an absorption change (mm −1 ) and the area over which that change occurs (mm 2 ) will give an estimate of the optical density change that would be measured by that channel as a result of that absorption change. An absorption change of 0.001 mm −1 over an area of 100 mm 2 is a likely upper limit for what should be expected during functional activation experiments. Thus, if we observe a sensitivity of 0.1 mm −1 for a specific region with a specific measurement and multiply by 0.001 mm −1 and 100 mm 2 , we would expect an optical density change of 0.01. For comparison, the heartbeat typically generates an optical density change on the order of 0.01. The sensitivity values are displayed logarithmically with a default range of 0.01 to 1, or −2 to 0 in log10 units. This can be manually changed by the user in the "Colormap Threshold" edit box (Fig. 11). Figure 11 demonstrates how probe geometry can impact sensitivity characteristics. In Fig. 11(a), the square probe geometry covers considerably more cortical area than the probe in Fig. 11(b), but the second probe geometry, a high-density probe with overlapping measurements, results in a more even sensitivity distribution in the cortical areas that it covers. Note that both probes employ the same number of sources.

Imaging Metrics
The forward matrix, i.e., sensitivity profiles, described above provides the transformation from an image of changes in the absorption coefficient in the cortex to the corresponding changes in optical density measured by each SD pair. Given experimentally measured changes in optical density and this forward matrix, it is possible to reconstruct an image of the changes in absorption coefficient in the cortex. This first requires a solution to the inverse problem, which consists of inverting the forward matrix. Reconstructing images by solving this inverse problem is often referred to as diffuse optical tomography. This procedure is summarized in the context used here in Refs. 12 and 27, and more detail of the general diffuse optical tomography inverse problem can be found in Ref. 28. In brief, image reconstruction is accomplished using Eq. (1), which is derived from the Rytov approximation 29 x ¼ A T ðAA T þ λIÞ −1 y; where x is a vector giving the spatial distribution of the absorption perturbation, A is the forward matrix obtained using the photon migration Monte Carlo (tMCimg) that describes the measurement sensitivity profiles, λ is a scalar regularization parameter given by Eq. (2), I is an identity matrix, and y is a vector of the measurements given as optical density changes. The regularization parameter is given by where α is a regularization scaling parameter. This regularization is required to smooth the image to compensate for the fact that there are typically significantly fewer measurements y in than unknowns in x. In addition to usually being underdetermined, the image reconstruction inverse problem is also ill posed indicating that noise in the measurements tend to be amplified into even greater noise in the image. 27,28 Regularization can be thought as a smoothing process to filter this noise in the image. When the "Calculate Metrics" button is pressed in the "Image Recon" panel, the following procedure is performed to calculate the localization error and resolution for a given probe design across all surface elements that exceed the user defined "Sensitivity Threshold." The user specifies the alpha regularization scaling parameter in the "Regularization" edit box and the "Sensitivity Threshold" in the corresponding edit box of the "Image Recon" panel. These procedures are similar to what is described in Cooper et al., 12 and are repeated with the "point" absorber being placed sequentially at each surface element that exceeds the "Sensitivity Threshold." A point absorber is created at a single surface element on the cortical surface to represent the true center of activation.
Simulated sensor measurements arising from that localized absorber are calculated using the forward matrix.
An image of the activation is reconstructed by solving the inverse problem in Eq. (1) above using the user defined "Regularization" scaling parameter, the first parameter in the "Image Recon" panel.
The "Image Threshold," the third parameter in the "Image Recon" panel, is applied to the image to define the "mass" of the reconstructed activation. The threshold is a fraction of the image's maximum value and all parts of the image greater than this threshold are included as part of the "mass" of the activation.
The centroid of the activation is found by calculating the average position of the surface elements in the activation "mass" weighted by the image intensity for each surface element. Specifically, r CM ¼ Σ i I i r i ∕Σ i I i , where r CM is the position of the center of mass, and we sum over surface elements i with intensity I i at position r i . The sum is only over the surface elements that are part of the "mass" of activation.
The Euclidean distance between the true and reconstructed centers of activation is calculated, which represents the localization error for an activation occurring in this surface element.
The resolution for an activation occurring at this surface element is defined by r CM ¼ Σ i I i jr i − r CM j∕Σ i I i . Again, the sum is only over the surface elements that are part of the "mass" of activation.
This process deviates from that described in Ref. 12 by one step. Cooper et al. 12 diffuses the "true" point absorber into a smooth ∼10 mm full width half maximum Gaussian. AtlasViewer does not perform this step in order to reduce computational requirements, but given the diffuse nature of the sensitivity profiles, and the process of regularization, this has a minimal impact on the reported results. After this process is complete, the user can display the localization error [ Fig. 12(a)] or resolution [ Fig. 12(b)] profiles instead of sensitivity, using the provided check boxes in the "Image Recon" panel. The localization error and resolution of a probe are both important factors when evaluating designs used in studies where image reconstruction will be conducted. Evaluating these metrics using AtlasViewer provides quantitative measures for how accurate the location of an imaged activation centroid is as well as the expected resolution.

User-Supplied Head Anatomies for Individual Subjects
When MRI data are available for an fNIRS subject, their structural data may be imported into AtlasViewer after it has been processed by FreeSurfer 30,31 and separated into surfaces using the "write_surf.m" script to save the pial mesh. It is assumed that the user already has very good surfaces created using FreeSurfer before beginning this process. Surfaces of the brain and head can be created by others means, of which there are many such methods available, but the results need to be saved in FreeSurfer format using the write_surf.m script provided with AtlasViewer.
The following two files are required, "headsurf.mesh" and "pialsurf.mesh," and they should be in the "anatomical" subdirectory of the subject folder. Once these two files have been prepared, the user can use the MATLAB ® script "create_HeadVox.m" Fig. 11 (a) The probe in the upper-left panel demonstrates how eight sources and 14 detectors can be arranged to provide moderately even coverage over an 18 × 9 cm 2 rectangle. (b) Using the forward matrix to generate a sensitivity profile, the upper-right panel shows that the resulting probe neatly wraps around the posterior portion of the scalp and provides sufficient coverage of many of the visual cortical regions. (c) The lower-left panel illustrates how 8 sources and 20 detectors can be arranged in a denser geometry, which covers only 10 × 6 cm 2 , a reduction in area by a factor of 2.7 compared to the square geometry. (d) The lower-right panel reveals that while the field of view has been significantly decreased, the sensitivity profile within that field is more evenly distributed, which indicates the potential trade-off to be considered in experiment design. The color scale depicts the sensitivity logarithmically from 0.01 to 1.
(available at Ref. 32) for producing the several additional files needed to use a user supplied anatomy in AtlasViewer. Briefly, the process is to run the script "create_HeadVox.m" to generate the files "headvol.vox," "headvol_dims.txt," "headvol_tiss_type.txt," "headvol_dims.txt," "headsurf2vol.txt," "pialsurf2vol.txt," and "refpts2vol.txt." All of these files are saved in the "anatomical" subfolder of the subject directory. The file "headvol.vox" is a 3-D volume of voxels designating the head and pial surfaces. The labels used are "0" for air, "1" for extracerebral tissue between the head and pial surfaces, and "2" for brain tissue inside the pial surface. The differentiation between these volumes is critical for visualization ( Fig. 1), probe registration to the scalp (Fig. 4), and photon migration in the Monte Carlo random walk (Sec. 4.1), upon which all image analysis is dependent. Once these files are created and saved in the "anatomical" subfolder, the user can then load the subject-specific anatomy by running AtlasViewer. The last step is to define the 10-20 scalp reference points. This is accomplished via the menu item "Tool → Find Ref Points," which will open a new window that allows the user to select and save the five anchor reference points Nz, Iz, A1, A2, and Cz. Once these are saved, the user should then use the menu item "Tool → Recalculate 10-20 pts" to generate the positions of all 10-20 reference points. 5 At this point, all of the AtlasViewer features described above can be used on this user supplied head anatomy.

Conclusion
AtlasViewer provides a combination of tools to aid the development of fNIRS studies and the analysis of their experimental data. Through the use of the probe design tool and sensitivity analyses, it is possible to accelerate the development of optimized fNIRS probes to measure specific cortical regions, and to quantify the sensitivity and imaging performance that the fNIRS probes will have to those cortical regions. We are actively working on integrating AtlasViewer with the open-source fNIRS signal processing software package Homer to permit image reconstructions to be performed on experimental data and visualized. Homer will preprocess the experimental data, then AtlasViewer will utilize the measurement sensitivity profiles it generated to perform the image reconstruction and visualize the results. The images will be reconstructed on the cortical surface, but features are also being added to exploit the ability of high-density measurements to distinguish superficial scalp signals from deeper brain signals and images that will be reconstructed in the scalp and cortex. These image reconstruction procedures will work on subject-specific anatomies as well as the atlases. The resolution map for the same probe. Variation in localization error is highly dependent on the underlying anatomical structure, while probe resolution is predominately a function of source and detector placement. The color scale is linear and spans from 0 to 10 mm as indicated in the "Colormap Thresh" edit box.