diff --git a/DESCRIPTION b/DESCRIPTION index 776c1ff..b431935 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: extrantsr Type: Package Title: Extra Functions to Build on the 'ANTsR' Package -Version: 3.9.12.1 +Version: 3.9.13 Authors@R: c(person(given = "John", family = "Muschelli", email = "muschellij2@gmail.com", @@ -15,10 +15,12 @@ Imports: methods, stats, grDevices, graphics, utils, oro.nifti, ANTsR 2.17.1), WhiteStripe, matrixStats, R.matlab, abind, R.utils, plyr, RNifti, stapler BugReports: https://github.com/muschellij2/extrantsr/issues -RoxygenNote: 7.0.1 +RoxygenNote: 7.1.0 Remotes: muschellij2/neurobase, muschellij2/fslr, bjw34032/oro.nifti, muschellij2/kirby21.t1, ANTsX/ANTsR, ANTsX/ANTsRCore, muschellij2/stapler +SystemRequirements: FSL Suggests: knitr, rmarkdown, kirby21.t1, covr, neuroim VignetteBuilder: knitr Encoding: UTF-8 +FSL: true diff --git a/R/face_removal_mask_ants.R b/R/face_removal_mask_ants.R index 3c0febd..85794c3 100644 --- a/R/face_removal_mask_ants.R +++ b/R/face_removal_mask_ants.R @@ -19,7 +19,7 @@ #' #' @examples #' \donttest{ -#' if (have_fsl()) { +#' if (fslr::have_fsl()) { #' file = "~/Downloads/sample_T1_input.nii.gz" #' if (file.exists(file)) { #' mask = face_removal_mask_ants(file = file, diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..da7aee2 --- /dev/null +++ b/docs/404.html @@ -0,0 +1,157 @@ + + + +
+ + + + +GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. + ++ +
vignettes/brain_extract.Rmd
+ brain_extract.Rmd
All code for this document is located at here.
+In this tutorial we will discuss performing brain segmentation using the brain extraction tool (BET) in fsl
and a robust version using a wrapper function in extrantsr
, fslbet_robust
.
For this analysis, I will use one subject from the Kirby 21 data set. The kirby21.base
and kirby21.t1
packages are necessary for this analysis and have the data we will be working on. You need devtools to install these. Please refer to installing devtools for additional instructions or troubleshooting.
packages = installed.packages() +packages = packages[, "Package"] +if (!"kirby21.t1" %in% packages) { + devtools::install_github("muschellij2/kirby21.t1") +}
We will use the get_image_filenames_df
function to extract the filenames on our hard disk for the T1 image.
library(kirby21.t1) +t1_fname = get_t1_filenames( + ids = 113, + visits = 1) +if (is.null(t1_fname)) { + dl = TRUE +} else { + dl = !file.exists(t1_fname) +} +if (dl) { + url = paste0("https://raw.githubusercontent.com/muschellij2/kirby21.t1", "/master/inst/visit_1/113/113-01-T1.nii.gz") + t1_fname = tempfile(fileext = ".nii.gz") + download.file(url, t1_fname) +}
Let’s take a look at the T1-weighted image.
+t1 = readnii(t1_fname) +ortho2(t1)
Here we see the brain and other parts of the image are present. Most notably, the neck of the subject was imaged. Sometimes this can cause problems with segmentation and image registration.
+Here we will use FSL’s Brain Extraction Tool (BET) to extract the brain tissue from the rest of the image.
+if (have.fsl()) { + ss_naive = fslbet(infile = t1_fname) +}
bet2 "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpoO1dC0/file79775059eaca.nii.gz" "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpoO1dC0/file797759147a60"
+if (have.fsl()) { + ortho2(ss_naive) +}
We see that naively, BET does not perform well for this image.
+Here we will use FSL’s Brain Extraction Tool (BET) to extract the brain tissue from the rest of the image. We use the modification of BET in extrantsr
, which is called through fslbet_robust
. In fslbet_robust
, the image is corrected using the N4 inhomogeneity correction. The neck of the T1 image is then removed and then BET is run, the center of gravity (COG) is estimated, and BET is run with this new COG. We used a procedure where the neck is removed in 2 registration steps, which is more robust than just the one (which is the default).
We will do the bias correction explicitly here:
+n4img = bias_correct( + t1_fname, + correction = "N4", + retimg = FALSE, + outfile = tempfile(fileext = ".nii.gz"), + verbose = FALSE) +if (have.fsl()) { + template.file = fslr::mni_fname(brain = TRUE) + template.mask = fslr::mni_fname(brain = TRUE, mask = TRUE) + removed_neck = extrantsr::double_remove_neck( + n4img, + template.file = template.file, + template.mask = template.mask) + ortho2(removed_neck) + double_ortho(t1, removed_neck) +}
# Registration to template
+# Swapping Dimensions
+fslhd "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpoO1dC0/file79772836aba.nii.gz"
+fslorient -getorient "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpoO1dC0/file79772836aba.nii.gz"
+fslswapdim "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpoO1dC0/file79772836aba.nii.gz" RL PA IS "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpoO1dC0/file79777bb63f4f";
+# Running Registration of file to template
+# Applying Registration output is
+$warpedmovout
+antsImage
+ Pixel Type : float
+ Components Per Pixel: 1
+ Dimensions : 170x256x256
+ Voxel Spacing : 1.20000004768372x1x1
+ Origin : 0 255 0
+ Direction : 1 0 0 0 -1 0 0 0 1
+
+
+$warpedfixout
+antsImage
+ Pixel Type : float
+ Components Per Pixel: 1
+ Dimensions : 182x218x182
+ Voxel Spacing : 1x1x1
+ Origin : -90 126 -72
+ Direction : 1 0 0 0 -1 0 0 0 1
+
+
+$fwdtransforms
+[1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpoO1dC0/file79772d3954f20GenericAffine.mat"
+
+$invtransforms
+[1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpoO1dC0/file79772d3954f20GenericAffine.mat"
+
+$prev_transforms
+character(0)
+# Applying Transformations to file
+# Applying Transforms to other.files
+# Writing out file
+# Writing out other.files
+# Removing Warping images
+# Reading data back into R
+# Reading in Transformed data
+# Dropping slices not in mask
+# Swapping Dimensions Back
+fslswapdim "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpoO1dC0/file797775d57de0.nii.gz" LR AP IS "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpoO1dC0/file7977133b3990";
+# Registration to template
+# Swapping Dimensions
+fslhd "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpoO1dC0/file7977154026cd.nii.gz"
+fslorient -getorient "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpoO1dC0/file7977154026cd.nii.gz"
+fslswapdim "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpoO1dC0/file7977154026cd.nii.gz" RL PA IS "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpoO1dC0/file79774c588ee0";
+# Running Registration of file to template
+# Applying Registration output is
+$warpedmovout
+antsImage
+ Pixel Type : float
+ Components Per Pixel: 1
+ Dimensions : 170x256x256
+ Voxel Spacing : 1.20000004768372x1x1
+ Origin : 0 255 0
+ Direction : 1 0 0 0 -1 0 0 0 1
+
+
+$warpedfixout
+antsImage
+ Pixel Type : float
+ Components Per Pixel: 1
+ Dimensions : 182x218x182
+ Voxel Spacing : 1x1x1
+ Origin : -90 126 -72
+ Direction : 1 0 0 0 -1 0 0 0 1
+
+
+$fwdtransforms
+[1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpoO1dC0/file7977690819f20GenericAffine.mat"
+
+$invtransforms
+[1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpoO1dC0/file7977690819f20GenericAffine.mat"
+
+$prev_transforms
+character(0)
+# Applying Transformations to file
+# Applying Transforms to other.files
+# Writing out file
+# Writing out other.files
+# Removing Warping images
+# Reading data back into R
+# Reading in Transformed data
+# Dropping slices not in mask
+# Swapping Dimensions Back
+fslswapdim "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpoO1dC0/file797714a76102.nii.gz" LR AP IS "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpoO1dC0/file797778d1d4e5";
+
+Let’s look at the skull-stripped image after doing all these steps.
+if (have.fsl()) { + ss = extrantsr::fslbet_robust(t1_fname, + remover = "double_remove_neck", recog = FALSE) + ortho2(ss) +}
Here we see the skull-stripped image. But did we drop out “brain areas”?
+if (have.fsl()) { + alpha = function(col, alpha = 1) { + cols = t(col2rgb(col, alpha = FALSE)/255) + rgb(cols, alpha = alpha) + } + ortho2(t1, ss > 0, col.y = alpha("red", 0.5)) +}
We can again use dropEmptyImageDimensions
to remove extraneous slices, which helps with reducing storage of the image on disk, zooming in while plotting, and may aid registration.
if (have.fsl()) { + ss_red = dropEmptyImageDimensions(ss) + ortho2(ss_red) +}
Again, we can see the zoomed-in view of the image now.
+The goal of extrantsr is to build on the ANTsR
Package.
You can install extrantsr
from github with:
# install.packages("devtools") +devtools::install_github("muschellij2/extrantsr")
origin
from antsImage
or nifti
+objects — origin • extrantsrorigin
from antsImage
or nifti
+objectsR/zzz_accessors.R
+ accessor-methods.Rd
Methods that act on the slots
of the
+antsImage
or nifti
object
origin(object) + +# S4 method for antsImage +origin(object) + +origin(object) <- value + +# S4 method for antsImage +origin(object) <- value + +# S4 method for anlz +origin(object) <- value+ +
object | +is an object of class |
+
---|---|
value | +is the value to assign to the slot. |
+
Plots series of Images for slices of antsImage
+ants.overlay( + img, + oimg, + slices = 53, + col.x = gray(0:64/64), + col.y = "#FF0000FF", + ... +)+ +
img | +Image to be plotted |
+
---|---|
oimg | +image to be overlaid |
+
slices | +slice to be displayed |
+
col.x | +grayscale coloring for img |
+
col.y | +color for overlay |
+
... | +arguments to be passed to |
+
NIfTI data can be converted between antsImage
+(from the ANTsR package) and nifti S4 objects.
ants2oro( + img, + reorient = FALSE, + reference = NULL, + ..., + cleanup = TRUE, + drop_dim = TRUE +)+ +
img | +Object of class antsImage |
+
---|---|
reorient | +Reorientation passed to |
+
reference | +Object of class |
+
... | +Arguments passed to |
+
cleanup | +temporary files are deleted after they are read in |
+
drop_dim | +Should |
+
Object of class nifti
.
Wraps antsSetOrigin/antsSetDirection/antsSetSpacing
+and antsGetOrigin/antsGetDirection/antsGetSpacing
+to copy the information over. Finer control than
+antsCopyImageInfo
antsCopyOrigin(reference, target) + +antsCopyDirection(reference, target) + +antsCopySpacing(reference, target)+ +
reference | +
|
+
---|---|
target | +
|
+
target
object of class antsImage
+library(ANTsR)#>#> +#>#>+#> +#>#>+#> +#>#>+#> +#>
R/ants_apply_transforms.R
+ ants_apply_transforms-methods.Rd
Wraps antsApplyTransforms
but allows for
+nifti
objects from the oro.nifti
package
ants_apply_transforms(fixed, moving, transformlist, ...) + +# S4 method for ANY,list +ants_apply_transforms(fixed, moving, transformlist, ret_ants = FALSE, ...) + +# S4 method for ANY,character +ants_apply_transforms(fixed, moving, transformlist, ret_ants = FALSE, ...) + +# S4 method for ANY,ANY +ants_apply_transforms(fixed, moving, transformlist, ret_ants = FALSE, ...)+ +
fixed | +image defining domain into which the moving image is transformed. |
+
---|---|
moving | +image to be mapped to fixed space. |
+
transformlist | +character vector of transforms generated by
+ |
+
... | +Arguments to be passed to |
+
ret_ants | +if |
+
Either nifti
object or list of nifti objects
antsApplyTransforms
This function performs registration to a template +using ANTsR and SyN transformation, carry out the transformation +on other images, and can back-transform atlases +in template space to the native space of the iimage
+ants_regwrite( + filename, + skull_strip = FALSE, + correct = FALSE, + correction = "N3", + retimg = TRUE, + outfile = NULL, + template.file = file.path(fsldir(), "data", "standard", "MNI152_T1_1mm_brain.nii.gz"), + interpolator = "Linear", + other.files = NULL, + other.outfiles = NULL, + native.cereb = FALSE, + native.fname = NULL, + atlas.file = NULL, + typeofTransform = "SyN", + remove.warp = TRUE, + outprefix = NULL, + bet.opts = "-B -f 0.1 -v", + betcmd = "bet", + verbose = TRUE, + reproducible = TRUE, + seed = 1, + ... +)+ +
filename | +filename of T1 image |
+
---|---|
skull_strip | +do skull stripping with FSL BET |
+
correct | +do Bias correction |
+
correction | +N3 or N4 correction, see |
+
retimg | +return a nifti object from function |
+
outfile | +output filename should have .nii or .nii.gz +extension |
+
template.file | +Filename of template to warp to |
+
interpolator | +interpolation done for
+ |
+
other.files | +Filenames of other iamges to be +transformed with the T1 |
+
other.outfiles | +Output filenames of |
+
native.cereb | +Logical indicating if native cerebellum should be
+created to |
+
native.fname | +filename of native cerebellum file |
+
atlas.file | +Filename of atlas used for warping labels |
+
typeofTransform | +type of transformed used, passed to
+ |
+
remove.warp | +(logical) Should warping images be deleted? |
+
outprefix | +Character path of where the warp files should be stored.
+Required if |
+
bet.opts | +Options passed to |
+
betcmd | +BET command used, passed to |
+
verbose | +Print diagnostic messages |
+
reproducible | +Sets the seed and
+ |
+
seed | +will execute
+ |
+
... | +arguments to |
+
NULL or object of class nifti for transformed T1 image
+ +R/applyEmptyImageDimensions.R
+ applyEmptyImageDimensions-methods.Rd
Simple wrapper for subsetting an image with indices, +dropping empty dimensions.
+# S4 method for antsImage +applyEmptyImageDimensions(img, inds, reorient = FALSE, ...)+ +
img | +image, nifti object, or array |
+
---|---|
inds | +indices of subset from |
+
reorient | +Should image be reoriented if a filename |
+
... | +not used |
+
Object of class nifti
or array
if nifti
+is not supplied
Takes in an input file, set of registrations, +and a set of template structures and applies the registrations, +with a different interpolator if necessary
+apply_malf_regs( + infile, + regs, + template.structs, + keep_images = TRUE, + outfiles = NULL, + inverted = FALSE, + interpolator = NULL, + verbose = TRUE, + ... +)+ +
infile | +Input Image file |
+
---|---|
regs | +List of registrations from |
+
template.structs | +Template gold standards to apply
+registration into |
+
keep_images | +Keep the |
+
outfiles | +Output filenames for |
+
inverted | +Should the MALF be inverted (inverse transforms are used +instead of forward) |
+
interpolator | +interpolation done for
+ |
+
verbose | +Print diagnostic output |
+
... | +Arguments to be passed to |
+
The output filename or the nifti image or list of registrations and +output file
+ +Simple check to see if input is character, list, nifti
,
+or class antsImage
apply_multi_reg(infiles, transformlist, fixed, ...) + +# S4 method for list,list +apply_multi_reg(infiles, transformlist, fixed, ...) + +# S4 method for character,list +apply_multi_reg(infiles, transformlist, fixed, ...) + +# S4 method for antsImage,character +apply_multi_reg(infiles, transformlist, fixed, ...) + +# S4 method for nifti,character +apply_multi_reg(infiles, transformlist, fixed, ...)+ +
infiles | +Input image files |
+
---|---|
transformlist | +list or character vector of transforms generated +by antsRegistration where each transform is a filename. |
+
fixed | +fixed image defining domain into which the infiles image +is transformed |
+
... | +Arguments passed to |
+
Object of class nifti
antsApplyTransforms
This function wraps ANTsR bias field corrections and returns +nifti objects
+bias_correct( + file, + correction = c("N3", "N4", "n3", "n4"), + outfile = NULL, + retimg = TRUE, + reorient = FALSE, + shrinkfactor = "4", + mask = NULL, + verbose = TRUE, + ... +) + +bias_correct_ants( + file, + correction = c("N3", "N4", "n3", "n4"), + shrinkfactor = "4", + mask = NULL, + verbose = TRUE, + ... +)+ +
file | +(character) image to be manipulated |
+
---|---|
correction | +(character) N3 or N4 correction? |
+
outfile | +(character) resultant image name (optional) |
+
retimg | +(logical) return image of class nifti |
+
reorient | +(logical) If retimg, should file be reoriented when read in?
+Passed to |
+
shrinkfactor | +Shrink factor passed to
+ |
+
mask | +Mask to pass to |
+
verbose | +print diagnostic output. |
+
... | +additional arguments passed to
+ |
+
If retimg
then object of class nifti. Otherwise,
+Result from system command, depends if intern is TRUE or FALSE.
This function wraps fslbet
and
+bias_correct
, performing bias correction first
bias_ss( + filename, + maskfile = NULL, + outfile = tempfile(fileext = ".nii.gz"), + skull_strip = TRUE, + bet.opts = "", + betcmd = "bet", + correct = TRUE, + correction = "N3", + shrinkfactor = "4", + retimg = TRUE, + reorient = FALSE, + verbose = TRUE, + ... +)+ +
filename | +filename to be processed |
+
---|---|
maskfile | +filename of masked to be passed in, otherwise bet is performed |
+
outfile | +output filename with extension (e.g. |
+
skull_strip | +should skull stripping be done |
+
bet.opts | +options for fslbet |
+
betcmd | +bet command to be used see |
+
correct | +should n3 correction be done stripping be done |
+
correction | +correction method used see |
+
shrinkfactor | +correction method used see |
+
retimg | +(logical) return image of class nifti |
+
reorient | +(logical) If retimg, should file be reoriented when read in?
+Passed to |
+
verbose | +Diagnostic output |
+
... | +passed to |
+
Filename of output file or object of class nifti
+This function wraps abpN4
and
+abpBrainExtraction
for nifti
images with additional checks
brain_extract( + img, + template, + template.mask, + typeofTransform = c("SyNabp", "SyN"), + correct = TRUE, + reproducible = TRUE, + seed = 1, + ... +)+ +
img | +Image for brain extraction, nifti, character or antsImage |
+
---|---|
template | +Template image with mask, nifti, character or antsImage |
+
template.mask | +Template brain mask |
+
typeofTransform | +registration type: 'SyNabp' (better, slower), +'SyN' (fast) |
+
correct | +Should |
+
reproducible | +Sets the seed and
+ |
+
seed | +will execute
+ |
+
... | +additional arguments passed to |
+
A list of the brain image, brain mask, k-means segmentation, +and transformations.
+ +Simple wrapper for antsImageRead
and
+antsImageWrite
for conversion of image file types.
+For example, NRRD files with nhdr/raw file formats can be converted to
+.nii.gz
.
c3d(infile, outfile, ...)+ +
infile | +input filename |
+
---|---|
outfile | +output filename with extension |
+
... | +arguments to be passed to |
+
Output from antsImageWrite
Simple check to see if input is character, list, nifti
,
+or class antsImage
# S4 method for nifti +check_ants(x, ...)+ +
x | +character path of image or +an object of class antsImage |
+
---|---|
... | +arguments passed to |
+
antsImage object
+ +R/check_nifti.R
+ check_nifti-methods.Rd
Simple check to see if input is character or of +class nifti
+# S4 method for antsImage +check_nifti( + x, + reorient = FALSE, + allow.array = FALSE, + fast = FALSE, + need_header = TRUE, + ... +)+ +
x | +character path of image or +an object of class nifti, or array |
+
---|---|
reorient | +(logical) passed to |
+
allow.array | +(logical) Are array types allowed (TRUE) or +should there be an error if the object is not character or class +nifti. |
+
fast | +not used for |
+
need_header | +if |
+
... | +additional options to pass to |
+
nifti object or array if allow.array=TRUE and x is an array
+readnii
Ensures the output to be a character filename (or vector) from an input
+image or nifti
.
# S4 method for antsImage +checkimg(file, allow_array = FALSE, ...)+ +
file | +character or |
+
---|---|
allow_array | +allow arrays to be passed in |
+
... | +options passed to |
+
R/compose_transform_to_file.R
+ compose_transform_to_file.Rd
This is a thin wrapper for antsApplyTransforms
but
+is specifically for composing a transform and getting a file out.
compose_transform_to_file( + fixed, + moving, + transformlist = NULL, + output_prefix = NULL +)+ +
fixed | +fixed image defining domain into which the moving image is transformed. |
+
---|---|
moving | +moving image to be mapped to fixed space. |
+
transformlist | +haracter vector of transforms generated by
+ |
+
output_prefix | +Prefix of output filename to return. The prefix will
+add |
+
A character filename
+ ++library(ANTsR) +fixed <- antsImageRead( getANTsRData("r16") ,2) +moving <- antsImageRead( getANTsRData("r64") ,2) +fixed <- resampleImage(fixed,c(64,64),1,0) +moving <- resampleImage(moving,c(64,64),1,0) +mytx <- antsRegistration(fixed=fixed , moving=moving , + typeofTransform = c("SyN"), + verbose = TRUE + ) +composed <- compose_transform_to_file( +fixed=fixed, moving=moving, transformlist=mytx$fwdtransforms)
Calculates the neighborhood of 2 registered images, and then +does the correlation of each neighbor with itself in the other imaging modality
+corr_img( + img1, + img2, + mask = NULL, + radius = rep(1, 3), + method = c("pearson", "spearman"), + verbose = TRUE +)+ +
img1 | +image of class |
+
---|---|
img2 | +image of class |
+
mask | +Binary image of class |
+
radius | +vector of length 3 for number of voxels to go in each direction.
+Default is 27 neighbors (including voxel at center).
+Passed to |
+
method | +Type of correlation. |
+
verbose | +print diagnostic messages |
+
Object of class nifti
+if (FALSE) { +corr_img("T1_Image.nii.gz", "FLAIR_Image.nii.gz", mask = "Mask.nii.gz") +}
R/cort_thickness.R
+ cort_thickness.Rd
Wrapper for the kellyKapowski
function
+in ANTsR, that computes cortical thickness.
cort_thickness(seg, gray, white, ...) + +kk(seg, gray, white, ...)+ +
seg | +segmentation image |
+
---|---|
gray | +gray matter probability image |
+
white | +white matter probability image |
+
... | +arguments passed to |
+
Object of class nifti
.
Creates first (mean) through fourth (kurtosis) central moments, +as well as gradients and mean/sd image.
+create_moment( + img, + mask = NULL, + radius = rep(1, 3), + retimg = TRUE, + verbose = TRUE, + ... +)+ +
img | +Object of class |
+
---|---|
mask | +Object of class |
+
radius | +array of values for neighborhood radius (in voxels) |
+
retimg | +Should images (of class |
+
verbose | +print diagnostic messages |
+
... | +arguments to passed to |
+
List of images (of class nifti
) or
+a matrix (V by 6), where V is the number of voxels in the mask
This function flips the image over the left/right axis, then registers +the flipped image to the original image and then takes a difference
+diff_self(img, swapdim = TRUE, verbose = TRUE, reproducible = TRUE, seed = 1)+ +
img | +Object of class |
+
---|---|
swapdim | +Should the image be reoriented to RPI then flipped, registered, +then changed back? |
+
verbose | +Print diagnostic messages |
+
reproducible | +Sets the seed and
+ |
+
seed | +will execute
+ |
+
Object of class nifti
Wrapper for running remove_neck
twice, as some images
+require this if large number of slices of the neck or upper shoulders
+were scanned
double_remove_neck( + file, + template.file, + template.mask, + typeofTransform = "Rigid", + rep.value = 0, + swapdim = TRUE, + verbose = TRUE, + ret_mask = FALSE, + ... +)+ +
file | +File for neck removal - either filename or class nifti |
+
---|---|
template.file | +Template to warp to original image space |
+
template.mask | +Mask of template to use as rough brain mask. If
+ |
+
typeofTransform | +Transformation for template to image, passed to
+ |
+
rep.value | +Value to replace neck slices with |
+
swapdim | +Should the dimensions be swapped before registration, +and then reset after |
+
verbose | +Print out diagnostic messages |
+
ret_mask | +Should the mask be returned vs. the image? |
+
... | +Additional arguments passed to |
+
Object of class nifti
+ +R/emptyImageDimensionsMask.R
+ emptyImageDimensionsMask-methods.Rd
Make a mask of an image that has all irrelevant +values
+# S4 method for antsImage +emptyImageDimensionsMask(img, ..., reorient = FALSE)+ +
img | +nifti object |
+
---|---|
... | +Arguments to be passed to |
+
reorient | +Should image be reoriented if a filename? |
+
Object of class nifti
, with binary values
empty_dim_mask
is a shorthand for emptyImageDimensionsMask
+with all the same arguments.qQac vgfrew
getEmptyImageDimensions
R/face_removal_mask_ants.R
+ face_removal_mask_ants.Rd
Face Removal Mask using ANTs Registration
+face_removal_mask_ants( + file, + template = NULL, + face_mask = NULL, + outfile = NULL, + ..., + retimg = FALSE +) + +deface_image_ants(file, ...)+ +
file | +input image |
+
---|---|
template | +Template image to register input image to. Set
+to |
+
face_mask | +Mask of image, in same space as |
+
outfile | +Output file name |
+
... | +additional arguments to pass to
+ |
+
retimg | +(logical) return image of class nifti |
+
An image or filename depending on retimg
+# \donttest{ +if (fslr::have_fsl()) { + file = "~/Downloads/sample_T1_input.nii.gz" + if (file.exists(file)) { + mask = face_removal_mask_ants(file = file, + template = NULL, face_mask = NULL) + image = mask_img(file, mask) + } +} +# }
Fills in a binary image using iMath
,
+using dilation erosion but with zero padding built in.
fill_2d_z(img, fill_size = 7, verbose = TRUE, dilate = TRUE, erode = TRUE)+ +
img | +Object of class |
+
---|---|
fill_size | +Size of fill (in voxels) |
+
verbose | +Output diagnostic values |
+
dilate | +should the image be dilated. This and |
+
erode | +should the image be eroded This and |
+
Filled object with same class as img
Fills in a binary image using iMath
,
+using dilation erosion but with zero padding built in.
filler(img, fill_size = 7, verbose = TRUE, dilate = TRUE, erode = TRUE)+ +
img | +Object of class |
+
---|---|
fill_size | +Size of fill (in voxels) |
+
verbose | +Output diagnostic values |
+
dilate | +should the image be dilated. This and |
+
erode | +should the image be eroded This and |
+
Filled object with same class as img
Simple wrapper for setting non-finite values to zero
+# S4 method for antsImage +finite_img(img, replace = 0)+ +
img | +character path of image or
+an object of class |
+
---|---|
replace | +Value to replace non-finite values to |
+
image object
+ +R/fslbet_robust.R
+ fslbet_robust.Rd
Skull Stripping (using FSL's BET) a file using fslr
+functions and robustified by registration and neck removal
fslbet_robust( + img, + outfile = NULL, + retimg = TRUE, + correct = TRUE, + correction = "N4", + recog = TRUE, + reorient = FALSE, + bet.opts = "", + nvoxels = 0, + swapdim = TRUE, + remove.neck = TRUE, + remover = c("remove_neck", "double_remove_neck"), + robust.mask = FALSE, + rbm.voxels = 7, + template.file = file.path(fsldir(), "data/standard", "MNI152_T1_1mm_brain.nii.gz"), + template.mask = file.path(fsldir(), "data/standard", + "MNI152_T1_1mm_brain_mask.nii.gz"), + verbose = TRUE, + ... +)+ +
img | +(character) File to be skull stripped or object of class +nifti |
+
---|---|
outfile | +(character) output filename |
+
retimg | +(logical) return image of class nifti |
+
correct | +Perform bias field correction |
+
correction | +(character) N3 or N4 correction? |
+
recog | +Rerun bet with a new center of gravity (COG) estimate |
+
reorient | +(logical) If retimg, should file be reoriented when read in?
+Passed to |
+
bet.opts | +Options for |
+
nvoxels | +Number of voxels to dilate/erode. See |
+
swapdim | +Use |
+
remove.neck | +Run |
+
remover | +if |
+
robust.mask | +Run |
+
rbm.voxels | +Number of voxels to inflate mask for |
+
template.file | +Template to warp to original image space, passed to
+ |
+
template.mask | +Mask of template to use as rough brain mask, passed
+to |
+
verbose | +(logical) Should diagnostic output be printed? |
+
... | +additional arguments passed to |
+
Skull-stripped nifti
object
This function first thresholds an image, runs a rigid registration
+(default in remove_neck
) to drop any slices below the transformed
+skull stripped template to remove neck slices. The neck-removed image is
+then skull stripped using defaults in fslbet
. A new
+center of gravity is estiamted using cog
, then the image is
+skull stripped again using the new cog. After the skull stripped mask is
+created, the image is dilated and eroded using fslfill2
to
+fill holes using a box kernel with the number of voxels nvoxels
in
+all 3 directions.
Find center of gravity for each compoent of an image
+group_xyz2(img, k = 1)+ +
img | +Object of class |
+
---|---|
k | +Minimum number of voxels for a cluster/component.
+See |
+
Matrix of 3 columns of dimension indices.
+ +Compute Image Similarity Metrics
+image_similarity(image1, image2, image1_mask = NULL, image2_mask = NULL, ...)+ +
image1 | +Object of class |
+
---|---|
image2 | +Object of class |
+
image1_mask | +Mask for first image (optional) |
+
image2_mask | +Mask for second image (optional) |
+
... | +Additional arguments to pass to
+ |
+
A numeric value
+Not all metrics are symmetric.
+ ++library(ANTsRCore) +library(extrantsr) +x = getANTsRData( 'r16' ) +y = getANTsRData( 'r30' ) +image_similarity(x,y, type="MeanSquares")#> [1] 1300.522image_similarity(y,x, type="MeanSquares")#> [1] 1300.522+image_similarity(x,y, type="Correlation")#> [1] -0.8218697image_similarity(y,x, type="Correlation")#> [1] -0.8218697+# NOT SYMMETRIC +image_similarity(x,y, type="MattesMutualInformation")#> [1] -0.5060095image_similarity(y,x, type="MattesMutualInformation")#> [1] -0.5059599#> [1] -0.5278006#> [1] -0.5261494+image_similarity(x,y, type="ANTSNeighborhoodCorrelation")#> [1] -0.7409918image_similarity(y,x, type="ANTSNeighborhoodCorrelation")#> [1] -0.7409918image_similarity(x,y, type="JointHistogramMutualInformation")#> [1] -0.7837214image_similarity(y,x, type="JointHistogramMutualInformation")#> [1] -0.7837214image_similarity(x,y, type="Demons")#> [1] 1300.522image_similarity(y,x, type="Demons")#> [1] 1300.522
Calculates the neighborhood of multiple images, and then +does the covariance of each neighbor with itself in the other imaging modality
+img_cov_matrix( + imgs, + mask = NULL, + radius = rep(1, 3), + method = c("pearson", "spearman"), + center = TRUE, + scale = FALSE, + verbose = TRUE +)+ +
imgs | +list of images of class |
+
---|---|
mask | +Binary image of class |
+
radius | +vector of length 3 for number of voxels to go in each direction.
+Default is 27 neighbors (including voxel at center).
+Passed to |
+
method | +Type of correlation. If pearson, scaling done on original data.
+If spearman, the ranks. If you want a covariance, you simply need to do
+ |
+
center | +Should the data be centered |
+
scale | +Should the data be scaled |
+
verbose | +print diagnostic messages |
+
List of matrix of covariances for each voxel and the order the columns +are in.
+#' @export
+Divisor is n - 1
.
Get the entropy for an entire image using density binning
+img_density_entropy(img, mask = NULL, base = exp(1), ...)+ +
img | +object of class |
+
---|---|
mask | +binary object of class |
+
base | +Base to take the log for the entropy. Default is e |
+
... | +Additional arguments to pass to |
+
+library(oro.nifti)#>#>#>+#> +#>#>#> +#>#>+#> +#>#>+#> +#>#> [1] 5.321614
Get the entropy for an entire image using histogram binning
+img_hist_entropy(img, mask = NULL, breaks = 2000, base = exp(1), ...)+ +
img | +object of class |
+
---|---|
mask | +binary object of class |
+
breaks | +Number of breaks to pass to |
+
base | +Base to take the log for the entropy. Default is e |
+
... | +Additional arguments to pass to |
+
+library(oro.nifti) +arr = array(rnorm(100^3), dim = rep(100, 3)) +img = oro.nifti::nifti(arr) +img_hist_entropy(img)#> [1] 6.71553
+ All functions+ + |
+ |
---|---|
+ + | +Extract Image Attributes |
+
+ + | +Extract values from antsImage from mask |
+
+ + | +Plot Lightbox for antsImage |
+
+ + | +Convert Between antsImage and nifti objects |
+
+ + | +Copy Information of One Image to Another |
+
+ + | +Apply ANTs transforms to nifti images |
+
+ + | +ANTs BWLabel Clusters of Certain Size |
+
+ + | +Registration to a Template |
+
+ + | +Apply Subsetting from Empty Image Dimensions |
+
+ + | +Apply MALF Registrations |
+
+ + | +Check if antsImage or read in |
+
+ + | +N3 or N4 Correct |
+
+ + | +Bias Field Correct then Skull Strip |
+
+ + | +Wrapper for ANTs brain extraction |
+
+ + | +Convert NeuroImage Types |
+
+ + | +Check if antsImage or read in |
+
+ + | +Check if nifti image or read in a nifti image |
+
+ + | +Force object to filename |
+
+ + | +Compose Transforms from ANTsR to a composite file |
+
+ + | +Neighborhood Correlation Image |
+
+ + | +Compute cortical thickness using Kelly Kapowski (ANTsR) |
+
+ + | +Create Neighborhood Momemts of an Image |
+
+ + | +Flipped Difference Image |
+
+ + | +Remove Neck Twice from a Scan |
+
+ + | +Make Mask from Empty Image Dimensions |
+
+ + | +Face Removal Mask using ANTs Registration |
+
+ + | +Image Mask Filler over each slice in Z-direction |
+
+ + | +Image Mask Filler |
+
+ + | +Finite Image |
+
+ + | +Robust Skull Stripping with COG estimation and Bias Correction |
+
+ + | +Center of Gravity for Multiple Components/Areas |
+
+ + | +Compute Image Similarity Metrics |
+
+ + | +Neighborhood Covariance Matrix |
+
+ + | +Image Entropy using density |
+
+ + | +Image Entropy using histograms |
+
+ + | +Split an Image into Multiple Sub-Images |
+
+ + | +Inpainting of images |
+
+
|
+ Image of the Determinant of the Jacobian |
+
+ + | +Label Clusters |
+
+ + | +Label Connected Components |
+
+ + | +Get Largest Component |
+
+ + | +Quantile Transform Voxel based on Neighborhood Distribution |
+
+ + | +Non-exported function to make png |
+
+ + | +Multi-Atlas Label Fusion |
+
+ + | +Multi-Atlas Label Fusion Registration |
+
+ + | +Apply Masking from Empty Image Dimensions |
+
+ + | +Multi-Registration |
+
+ + | +Two-Stage Multi-Registration of images |
+
+ + | +Calculates Mutual Information on nifti objects |
+
+ + | +Quick Tabulation for logical vectors |
+
+ + | +Four-Dimensional Bias-Field Correction |
+
+ + | +Get Neighborhood of Voxels from an Image |
+
+ + | +Get Neighborhood Matrix of Indices from an Image |
+
+ + | +Get Mask from nifti object |
+
+ + | +Perform iMath on nifti objects |
+
+ + | +OASIS Processing Pipeline |
+
+ + | +Convert Between nifti and antsImage |
+
+ + | +Orthographic Display, added options |
+
+ + | +Run Atropos for nifti objects |
+
+ + | +Run Atropos for nifti objects |
+
+ + | +Perona-Malik Anisotropic Filter |
+
+ + | +Extract Image pixdim attribute |
+
+ + | +Preprocess MRI acros visits |
+
+ + | +Within Visit Registration |
+
+ + | +Process filenames to ensure nifti and consistency |
+
+ + | +Read Transform List from ANTsR |
+
+ + | +Reapply MALF Operation |
+
+ + | +Flip Image with Registration |
+
+ + | +Flip Image with Registration |
+
+ + | +WhiteStripe Normalization |
+
+ + | +Z-score Normalization |
+
+ + | +Registration Wrapper function |
+
+ + | +Remove Neck from Image |
+
+ + | +Reorder Voxel Neighborhood |
+
+ + | +Set reproducible seeds and threads for ANTsR execution |
+
+ + | +Resample an image |
+
+ + | +Resample an Image to a Target Image |
+
+ + | +Robust Brain Mask from Template |
+
+ + | +Get Scaled Neighborhood of Voxels from an Image |
+
+ + | +Calculate Overlap Metrics |
+
+ + | +Gaussian smooth image using ANTsR |
+
+ + | +Standard MRI Preprocessing |
+
+ + | +Skull Strip then Bias Field Correct |
+
+ + | +Create Statistics Image |
+
+ + | +Subset a 4D image |
+
+ + | +Create temporary nii.gz file from antsImage |
+
+ + | +Get list of transforms that would likely be made with a specific `outprefix` |
+
+ + | +Within Visit Registration |
+
+ + | +Read Transform List from ANTsR |
+
+ + | +Zero pads an image |
+
+ + | +Create Z-score-to-Template Image |
+
Paints in the image with the mean/median from
+fill_mask
inpaint(img, input_mask, fill_mask, func = c("mean", "median"), ...)+ +
img | +image of class |
+
---|---|
input_mask | +mask to be painted in. |
+
fill_mask | +image mask to take the function (e.g. mean/median) of the image |
+
func | +Function to apply on the values. |
+
... | +Arguments to be passed to |
+
List of output image (outimg
) and
+statistic filled in (statistic
)
Image of the Determinant of the Jacobian
+jacobian_image( + fixed, + transformlist = NULL, + moving = NULL, + typeofTransform = "SyN", + ... +) + +log_jacobian_image( + fixed, + transformlist = NULL, + moving = NULL, + typeofTransform = "SyN", + ... +) + +geom_jacobian_image( + fixed, + transformlist = NULL, + moving = NULL, + typeofTransform = "SyN", + ... +) + +log_geom_jacobian_image( + fixed, + transformlist = NULL, + moving = NULL, + typeofTransform = "SyN", + ... +)+ +
fixed | +Fixed image in a registration |
+
---|---|
transformlist | +List of transformation of moving image to
+fixed image. Only one of |
+
moving | +Image to transform into |
+
typeofTransform | +If registration not done previously, +then transform to use for transformation. Should be non-linear. |
+
... | +additional arguments to pass to |
+
An image of the determinant of the Jacobian, the +transform list, and the fixed image.
+ ++library(extrantsr) +library(ANTsR) +library(methods) +fi<-antsImageRead( getANTsRData("r16") ,2) +mi<-antsImageRead( getANTsRData("r64") ,2) +fi<-resampleImage(fi,c(128,128),1,0) +mi<-resampleImage(mi,c(128,128),1,0) +mytx<-antsRegistration(fixed=fi , moving=mi, typeofTransform = c("SyN") ) +jac<-createJacobianDeterminantImage(fi,mytx$fwdtransforms[[1]],1) +jac = jacobian_image(fixed = fi, moving = mi, verbose = FALSE)
Label Clusters
+label_clusters(img, ..., retfile = FALSE)+ +
img | +input image |
+
---|---|
... | +additional arguments passed to |
+
retfile | +logical to indicate if an |
+
A antsImage
or a nifti
image, depending on
+retfile
Wrapper for oMath("GetLargestComponent")
largest_component(img, ..., retfile = FALSE)+ +
img | +Object of class |
+
---|---|
... | +Additional arguments passed to |
+
retfile | +logical to indicate if an |
+
Object of class nifti
R/local_quantile_img.R
+ local_quantile_img.Rd
Quantile Transform Voxel based on Neighborhood Distribution
+local_quantile_img(img, mask = NULL, radius = rep(1, 3), verbose = TRUE)+ +
img | +Object of class |
+
---|---|
mask | +Binary image of class |
+
radius | +vector of length 3 for number of voxels to go in each direction.
+Default is 27 neighbors (including voxel at center).
+Passed to |
+
verbose | +Print diagnostic messages |
+
An object of class nifti
+nim = oro.nifti::nifti(array(rnorm(10^3), dim = rep(10, 3))) +mask = nim > -1 +res = local_quantile_img(nim, mask = mask)#>#>#>#>+
Make my png
+makepng(outfile, addstub, ...)+ +
outfile | +Filename to be added to for png |
+
---|---|
addstub | +extension to add to outfile |
+
... | +arguments passed to |
+
Alpha level depending on device
+ +Takes in an input file and template images with +a set of template structures and creates a label fusion
+malf( + infile, + template.images, + template.structs, + inverted = FALSE, + keep_images = FALSE, + outfiles = NULL, + outfile = NULL, + retimg = TRUE, + func = "mode", + ties.method = "first", + keep_regs = FALSE, + outprefix = NULL, + interpolator = "NearestNeighbor", + typeofTransform = "SyN", + verbose = TRUE, + ... +)+ +
infile | +Input Image file |
+
---|---|
template.images | +Template Images to register
+to |
+
template.structs | +Template gold standards to apply
+registration into |
+
inverted | +Should the MALF be inverted +(infile to template then use inverse transforms) |
+
keep_images | +Keep the |
+
outfiles | +Output filenames for |
+
outfile | +Fused output filename |
+
retimg | +Return Image to user using |
+
func | +function to combine labels. See |
+
ties.method | +If |
+
keep_regs | +Keep list of registrations. If |
+
outprefix | +passed to |
+
interpolator | +interpolation done for
+ |
+
typeofTransform | +type of transformed used, passed to
+ |
+
verbose | +Print diagnostic output |
+
... | +Arguments to be passed to |
+
The output filename or the nifti image or list of registrations and +output file
+ +Takes in an input file and template images with +a set of template structures and registers them
+malf_registration( + infile, + template.images, + template.structs, + inverted = FALSE, + typeofTransform = "SyN", + interpolator = "NearestNeighbor", + keep_images = TRUE, + outfiles = NULL, + outprefix = NULL, + verbose = TRUE, + rerun_registration = TRUE, + image_interpolator = "Linear", + ... +)+ +
infile | +Input Image file |
+
---|---|
template.images | +Template Images to register
+to |
+
template.structs | +Template gold standards to apply
+registration into |
+
inverted | +Should the MALF be inverted +(infile to template then use inverse transforms) |
+
typeofTransform | +type of transformed used, passed to
+ |
+
interpolator | +interpolation done for
+ |
+
keep_images | +Keep the |
+
outfiles | +Output filenames for |
+
outprefix | +passed to |
+
verbose | +Print diagnostic output |
+
rerun_registration | +Should |
+
image_interpolator | +interpolation done for
+ |
+
... | +Arguments to be passed to |
+
List of registrations and +output files
+ +R/maskEmptyImageDimensions.R
+ maskEmptyImageDimensions-methods.Rd
Simple wrapper for replacing indices with a value
+# S4 method for antsImage +maskEmptyImageDimensions(img, inds, reorient = FALSE, mask.value = 0, ...)+ +
img | +image, nifti object, or array |
+
---|---|
inds | +indices of subset from |
+
reorient | +Should image be reoriented if a filename? |
+
mask.value | +Value to replace voxels outside the mask. |
+
... | +not used |
+
Object of class nifti
or array
if nifti
+is not supplied
apply_empty_dim
is a shorthand for
+maskEmptyImageDimensions
with all the same arguments.
getEmptyImageDimensions
,
+dropEmptyImageDimensions
Takes a list of images and registers them to a template, +keeping the registration information in a list.
+multi_reg( + infiles, + template.file, + outfiles = NULL, + typeofTransform = "SyN", + interpolator = "Linear", + outprefix = NULL, + retimg = TRUE, + verbose = TRUE, + ... +)+ +
infiles | +Input image files |
+
---|---|
template.file | +Template image to register +to |
+
outfiles | +Output filenames for |
+
typeofTransform | +type of transformed used, passed to
+ |
+
interpolator | +interpolation done for
+ |
+
outprefix | +Character path of where the warp files and transformations +should be stored. |
+
retimg | +Return image to user using |
+
verbose | +Print diagnostic output |
+
... | +Arguments to be passed to |
+
Output list of registered images and transformations
+ +Takes a list of images and registers them to a template, +takes a statistic image, and registers the list of images back to this +statistic image.
+multi_rereg(infiles, template.file, func = "mean", ...)+ +
infiles | +Input image files |
+
---|---|
template.file | +Template image to register to for first pass. +Second pass will be statistic image |
+
func | +Function to be passed to |
+
... | +Arguments to be passed to |
+
Output list of statistic image, +registered images to statistic image +and transformations
+The second stage will use the same arguments passed in ...
, but
+the template.file
will be the statistic image
R/mutual_information.R
+ mutual_information.Rd
Images are converted nifti
objects
+(from the oro.nifti package), an operation is performed using
+antsImageMutualInformation
mutual_information(image1, image2, ...)+ +
image1 | +Object of class |
+
---|---|
image2 | +Object of class |
+
... | +Additional arguments passed to
+ |
+
Numeric
+ ++
Speeds up on table for logical x and y
+my.tab(x, y, dnames = c("x", "y"))+ +
x | +Logical or 0/1 vector |
+
---|---|
y | +Logical or 0/1 vector |
+
dnames | +names for table |
+
table of x vs y
+ +Four-Dimensional Bias-Field Correction
+n4_4d(img, verbose = TRUE, correction = "N4", ...)+ +
img | +Image for N4 to be run, an antsImage |
+
---|---|
verbose | +Print diagnostic messages |
+
correction | +Correction to do (N4 or N3) |
+
... | +arguments to pass to |
+
An object of class antsImage
This function wraps the getNeighborhoodInMask
to
+be more friendly for R and nifti
objects
neighborhood( + img, + mask = NULL, + radius = rep(1, 3), + get.gradient = TRUE, + verbose = TRUE, + run_gc = TRUE, + ... +)+ +
img | +Object of class |
+
---|---|
mask | +Binary image of class |
+
radius | +vector of length 3 for number of voxels to go in each direction.
+Default is 27 neighbors (including voxel at center).
+Passed to |
+
get.gradient | +logical indicating if a matrix of gradients (at the center voxel) +should be returned in addition to the value matrix |
+
verbose | +Print diagnostic messages |
+
run_gc | +Experimental - trying to run with gc(); for memory cleanup. |
+
... | +arguments other than |
+
List similar to the output of
+getNeighborhoodInMask
R/neighborhood_index.R
+ neighborhood_index.Rd
This function wraps the neighborhood
to
+get the matrix of data in the format of array indices (not values of data)
neighborhood_index(img, ...)+ +
img | +Object of class |
+
---|---|
... | +arguments other than |
+
List similar to the output of neighborhood
Images are converted nifti
objects
+(from the oro.nifti package), an operation is performed using
+iMath
, and the result is a nifti
object.
oMath(img, ..., retfile = FALSE)+ +
img | +Object of class |
+
---|---|
... | +Additional arguments passed to |
+
retfile | +logical to indicate if an |
+
Object of class nifti
This function performs registration to a T1 template +using ANTsR transformation
+oasis( + filename, + skull_strip = TRUE, + skull_stripfile = NULL, + correct = TRUE, + normalize = TRUE, + normalize_file = NULL, + retimg = TRUE, + outfile = NULL, + template.file = file.path(fsldir(), "data", "standard", "MNI152_T1_1mm_brain.nii.gz"), + interpolator = "LanczosWindowedSinc", + other.files = NULL, + other.outfiles = NULL, + typeofTransform = "Rigid", + remove.warp = TRUE, + outprefix = NULL, + bet.opts = "-B -f 0.1 -v", + betcmd = "bet", + reproducible = TRUE, + seed = 1, + ... +)+ +
filename | +filename of T1 image |
+
---|---|
skull_strip | +do skull stripping with FSL BET |
+
skull_stripfile | +Output skull strip filename |
+
correct | +do N3 Bias correction |
+
normalize | +Normalize data using |
+
normalize_file | +
|
+
retimg | +return a nifti object from function |
+
outfile | +output filename should have .nii or .nii.gz +extension |
+
template.file | +Filename of template to warp to |
+
interpolator | +interpolation done for
+ |
+
other.files | +Filenames of other iamges to be +transformed with the T1 |
+
other.outfiles | +Output filenames of |
+
typeofTransform | +type of transformed used, passed to
+ |
+
remove.warp | +(logical) Should warping images be deleted? |
+
outprefix | +Character path of where the warp files should be stored.
+Required if |
+
bet.opts | +Options passed to |
+
betcmd | +BET command used, passed to |
+
reproducible | +Sets the seed and
+ |
+
seed | +will execute
+ |
+
... | +arguments to |
+
NULL or object of class nifti for transformed T1 image
+ +NIfTI data can be converted between nifti
+(from the oro.nifti package) and antsImage
objects.
oro2ants(img, reference = NULL, cleanup = TRUE, ...)+ +
img | +Object of class |
+
---|---|
reference | +Object of class |
+
cleanup | +temporary files are deleted after they are read in |
+
... | +arguments passed to |
+
Object of class antsImage
Wrapper for of neurobase
's ortho2
function
+to work with antsImages
# S4 method for antsImage +ortho2( + x, + y = NULL, + xyz = NULL, + w = 1, + col = gray(0:64/64), + col.y = hotmetal(), + zlim = NULL, + zlim.y = NULL, + NA.x = FALSE, + NA.y = TRUE, + crosshairs = TRUE, + col.crosshairs = "red", + xlab = "", + ylab = "", + axes = FALSE, + oma = c(0, 0, 0, ifelse(ycolorbar, 5, 0)), + mar = rep(0, 4), + bg = "black", + text = NULL, + text.color = "white", + text.cex = 2, + text.x = 32, + text.y = 32, + add.orient = TRUE, + mfrow = c(2, 2), + ybreaks = NULL, + breaks = NULL, + addlegend = FALSE, + leg.x = 32, + leg.y = 32, + legend, + leg.col, + leg.title = NULL, + leg.cex, + window = NULL, + ycolorbar = FALSE, + clabels = TRUE, + add = TRUE, + pdim = NULL, + useRaster = TRUE, + mask = NULL, + ... +) + +# S4 method for niftiImage +ortho2( + x, + y = NULL, + xyz = NULL, + w = 1, + col = gray(0:64/64), + col.y = oro.nifti::hotmetal(), + zlim = NULL, + zlim.y = NULL, + NA.x = FALSE, + NA.y = TRUE, + crosshairs = TRUE, + col.crosshairs = "red", + xlab = "", + ylab = "", + axes = FALSE, + oma = c(0, 0, 0, ifelse(ycolorbar, 5, 0)), + mar = rep(0, 4), + bg = "black", + text = NULL, + text.color = "white", + text.cex = 2, + text.x = 32, + text.y = 32, + add.orient = FALSE, + mfrow = c(2, 2), + ybreaks = NULL, + breaks = NULL, + addlegend = FALSE, + leg.x = 32, + leg.y = 32, + legend, + leg.col, + leg.title = NULL, + leg.cex, + window = NULL, + ycolorbar = FALSE, + clabels = TRUE, + add = TRUE, + pdim = NULL, + useRaster = is.null(y), + mask = NULL, + ... +)+ +
x | +is an object of class |
+
---|---|
y | +is an object of class |
+
xyz | +is the coordinate for the center of the crosshairs. |
+
w | +is the time point to be displayed (4D arrays only). |
+
col | +is grayscale (by default). |
+
col.y | +is hotmetal (by default). |
+
zlim | +is the minimum and maximum `z' values passed into image. |
+
zlim.y | +is the minimum and maximum `z' values passed into image +for the overlay. |
+
NA.x | +Set any values of 0 in |
+
NA.y | +Set any values of 0 in |
+
crosshairs | +is a logical value for the presence of crosshairs +in all three orthogonal planes (default = TRUE). |
+
col.crosshairs | +is the color of the crosshairs (default = red). |
+
xlab | +is set to "" since all margins are set to zero. |
+
ylab | +is set to "" since all margins are set to zero. |
+
axes | +is set to FALSE since all margins are set to zero. |
+
oma | +is the size of the outer margins in the par function. |
+
mar | +is the number of lines of margin in the par function. |
+
bg | +is the background color in the par function. |
+
text | +allows the user to specify text to appear in +the fourth (unused) pane. |
+
text.color | +is the color of the user-specified text +(default = ``white"). |
+
text.cex | +is the size of the user-specified text (default = 2). |
+
text.x | +x coordinate for text |
+
text.y | +y coordinate for text |
+
add.orient | +(logical) Add left/right, A/P, etc. orientation |
+
mfrow | +(numeric) layout of the 3 slices |
+
ybreaks | +(numeric) breaks for y to passed to
+ |
+
breaks | +(numeric) breaks for x to passed to
+ |
+
addlegend | +(logical) add legend? |
+
leg.x | +(numeric) x coord for legend |
+
leg.y | +(numeric) y coord for legend |
+
legend | +(character) legend text |
+
leg.col | +(character) Colors for legend |
+
leg.title | +(character) title for legend |
+
leg.cex | +(numeric) |
+
window | +(vector) Length-2 vector to limit image to certain range |
+
ycolorbar | +(logical) Should a colorbar for |
+
clabels | +Label for colorbar (see |
+
add | +Should the y-plot be added or its own plot? Used
+in |
+
pdim | +Pixel dimensions if passing in arrays. |
+
useRaster | +logical; if TRUE a bitmap raster is used to
+plot the image instead of polygons. Passed to
+ |
+
mask | +If a mask is passed, |
+
... | +other arguments to the image function may be provided here. |
+
This will NOT do ants2oro
to plot the image.
+If that is desired, users will have to do that before calling
+ortho2
.
Runs Atropos (a finite mixture model) but with more +robust inputs
+otropos( + a, + x, + m = "[0.2,1x1x1]", + verbose = TRUE, + ..., + make_mask = TRUE, + reset_origin = TRUE +)+ +
a | +Images to segment. Can be a |
+
---|---|
x | +Mask image. If none is supplied and |
+
m | +mrf parameters as a string, usually
+" |
+
verbose | +print diagnostic messages |
+
... | +Additional arguments to be passed to |
+
make_mask | +Logical indicating if mask should be created if
+ |
+
reset_origin | +Should |
+
Result of atropos
, but with nifti objects.
Runs otropos
but has different argument
+names to be more consistent with extrantsr
otropos2(img, mask = NULL, smoothing_factor = 0.2, radius = c(1, 1, 1), ...)+ +
img | +Images to segment. |
+
---|---|
mask | +Mask of Image |
+
smoothing_factor | +amount of smoothing in Markov random Field. +Increasing this number causes more smoothing whereas decreasing +the number lessens the smoothing. |
+
radius | +the mrf neighborhood. Length must equal the number
+of dimensions of |
+
... | +arguments to pass to |
+
otropos
, atropos
Wrapper for oMath("PeronaMalik")
perona_malik(img, n_iter, conductance, ..., retfile = FALSE)+ +
img | +Object of class |
+
---|---|
n_iter | +number of iterations |
+
conductance | +From ITK: The conductance parameter controls the +sensitivity of the conductance term in the basic anisotropic diffusion equation |
+
... | +Additional arguments passed to |
+
retfile | +logical to indicate if an |
+
Object of class nifti
This function performs preprocessing and registration +across visits and within visits
+preprocess_mri_across( + baseline_files, + followup_files, + baseline_outfiles, + followup_outfiles, + retimg = FALSE, + maskfile = NULL, + correct = TRUE, + correction = "N4", + skull_strip = TRUE, + bet.opts = "-B -f 0.1 -v", + betcmd = "bet", + within.transform = "Rigid", + within.interpolator = "LanczosWindowedSinc", + across.transform = within.transform, + across.interpolator = within.interpolator, + verbose = TRUE, + ... +)+ +
baseline_files | +filename of baseline images |
+
---|---|
followup_files | +filename of followup images |
+
baseline_outfiles | +output filenames for baseline images |
+
followup_outfiles | +output filenames for followup images |
+
retimg | +(logical) return list of images of class nifti |
+
maskfile | +Filename (or nifti object) of binary mask for baseline image. +If filename exists, skull stripping will be done by masking it. +If it does not, then skull stripping will get one from the baseline +image |
+
correct | +Perform bias field correction |
+
correction | +(character) N3 or N4 correction? |
+
skull_strip | +do Skull stripping with FSL BET |
+
bet.opts | +Options to pass to |
+
betcmd | +Command to pass to |
+
within.transform | +Transformation for within-visit registration |
+
within.interpolator | +Interpolator for within-visit registration |
+
across.transform | +Transformation for across-visit registration |
+
across.interpolator | +Interpolator for across-visit registration |
+
verbose | +print diagnostic outputs |
+
... | +arguments to |
+
list of objects from preprocess_mri_within
and
+registration
This function performs skull stripping of the first image, +within-visit registration using a rigid-body transformation, +inhomogeneity correction, and potentially re-correcting after skull stripping.
+preprocess_mri_within( + files, + outfiles = NULL, + correct = TRUE, + correction = "N4", + retimg = FALSE, + reorient = FALSE, + typeofTransform = "Rigid", + interpolator = "LanczosWindowedSinc", + skull_strip = FALSE, + bet.opts = "-B -f 0.1 -v", + betcmd = "bet", + maskfile = NULL, + correct_after_mask = FALSE, + verbose = TRUE, + ... +)+ +
files | +filenames (or nifti objects) of images to be processed. +Will register to the first scan |
+
---|---|
outfiles | +(character) name of output files, with extension |
+
correct | +do Bias field correction |
+
correction | +(character) N3 or N4 correction? |
+
retimg | +(logical) return list of images of class nifti |
+
reorient | +(logical) If retimg, should file be reoriented
+when read in?
+Passed to |
+
typeofTransform | +type of transformed used, passed to
+ |
+
interpolator | +Interpolation to be performed, passed to
+ |
+
skull_strip | +do Skull stripping with FSL BET |
+
bet.opts | +Options to pass to |
+
betcmd | +Command to pass to |
+
maskfile | +Filename (or nifti object) of mask for image to be +registered to |
+
correct_after_mask | +Should the inhomogeneity correction be run
+after masking. If |
+
verbose | +Diagnostic messages |
+
... | +arguments to |
+
List of outfiles, maskfile, and output from registration
.
R/preprocess_mri_across.R
+ process_filenames.Rd
Takes input and output filename, ensures the same +file extension, copies files, and checks all are character
+process_filenames(files, outfiles, force_nii = TRUE, copyfiles = TRUE)+ +
files | +input filenames |
+
---|---|
outfiles | +output filenames |
+
force_nii | +Force output filenames to have .nii |
+
copyfiles | +copy files to outfiles |
+
List of 2 elements: files of the filenames and outfiles +of output filenames
+ +Takes in an input file, set of registrations, +and a set of template structures and applies the registrations, +with a different interpolator if necessary, and then combines output
+reapply_malf( + infile, + regs, + template.structs, + keep_images = FALSE, + outfiles = NULL, + outfile = NULL, + retimg = TRUE, + func = "mode", + ties.method = "first", + interpolator = NULL, + verbose = TRUE, + ... +)+ +
infile | +Input Image file |
+
---|---|
regs | +List of registrations from |
+
template.structs | +Template gold standards to apply
+registration into |
+
keep_images | +Keep the |
+
outfiles | +Output filenames for |
+
outfile | +Fused output filename |
+
retimg | +Return Image to user using |
+
func | +function to combine labels. See |
+
ties.method | +If |
+
interpolator | +interpolation done for
+ |
+
verbose | +Print diagnostic output |
+
... | +Arguments to be passed to |
+
The output filename or the nifti image or list of registrations and +output file
+ +This function performs registration to a template
+using ANTsR and will run fslswapdim
reg_flip( + t1, + register = TRUE, + native = TRUE, + template.file = file.path(fsldir(), "data", "standard", paste0("MNI152_T1_1mm", + ifelse(is.null(mask), "", "_brain"), ".nii.gz")), + typeofTransform = c("Rigid", "Affine"), + interpolator = "LanczosWindowedSinc", + t1.outfile = NULL, + other.files = NULL, + other.outfiles = NULL, + mask = NULL, + mask.outfile = NULL, + verbose = TRUE, + a = "-x", + b = "y", + c = "z", + reproducible = TRUE, + seed = 1, + ... +)+ +
t1 | +filename (or nifti objects) of T1 image |
+
---|---|
register | +Register image to template file |
+
native | +If images are registered, should the native space +normalized image be returned? |
+
template.file | +Filename of template to warp to |
+
typeofTransform | +type of transformed used, passed to
+ |
+
interpolator | +Interpolation to be performed, passed to
+ |
+
t1.outfile | +Output filename of normalized T1 image |
+
other.files | +Character filenames or list of nifti objects to +normalize. In the same space as T1. |
+
other.outfiles | +Character filenames for output +normalized files. |
+
mask | +File or nifti image of brain mask |
+
mask.outfile | +Character filename for output +brain mask. |
+
verbose | +Print Diagnostic Messages |
+
a | +Option for x domain in |
+
b | +Option for y domain in |
+
c | +Option for z domain in |
+
reproducible | +Sets the seed and
+ |
+
seed | +will execute
+ |
+
... | +arguments to |
+
List of nifti objects or character filenames
+ +This function performs registration to a template
+using ANTsR and will run fslswapdim
reg_flip_img( + t1, + register = TRUE, + native = TRUE, + template.file = file.path(fsldir(), "data", "standard", paste0("MNI152_T1_1mm", + ifelse(is.null(mask), "", "_brain"), ".nii.gz")), + typeofTransform = c("Rigid", "Affine"), + interpolator = "LanczosWindowedSinc", + t1.outfile = NULL, + other.files = NULL, + other.outfiles = NULL, + mask = NULL, + mask.outfile = NULL, + verbose = TRUE, + flipx = FALSE, + flipy = FALSE, + flipz = FALSE, + reproducible = TRUE, + seed = 1, + ... +)+ +
t1 | +filename (or nifti objects) of T1 image |
+
---|---|
register | +Register image to template file |
+
native | +If images are registered, should the native space +normalized image be returned? |
+
template.file | +Filename of template to warp to |
+
typeofTransform | +type of transformed used, passed to
+ |
+
interpolator | +Interpolation to be performed, passed to
+ |
+
t1.outfile | +Output filename of normalized T1 image |
+
other.files | +Character filenames or list of nifti objects to +normalize. In the same space as T1. |
+
other.outfiles | +Character filenames for output +normalized files. |
+
mask | +File or nifti image of brain mask |
+
mask.outfile | +Character filename for output +brain mask. |
+
verbose | +Print Diagnostic Messages |
+
flipx | +Option for flipping x domain in |
+
flipy | +Option for flipping y domain in |
+
flipz | +Option for flipping z domain in |
+
reproducible | +Sets the seed and
+ |
+
seed | +will execute
+ |
+
... | +arguments to |
+
List of nifti objects or character filenames
+ +This function performs registration to a T1 template +using ANTsR and SyN transformation
+reg_whitestripe( + t1 = NULL, + t2 = NULL, + register = TRUE, + native = TRUE, + template.file = file.path(fsldir(), "data", "standard", paste0("MNI152_T1_1mm", + ifelse(is.null(mask), "", "_brain"), ".nii.gz")), + typeofTransform = c("Rigid", "Affine"), + interpolator = "LanczosWindowedSinc", + type = c("T1", "T2", "hybrid"), + t1.outfile = NULL, + t2.outfile = NULL, + other.files = NULL, + other.outfiles = NULL, + ws.outfile = NULL, + mask = NULL, + mask.outfile = NULL, + verbose = TRUE, + reproducible = TRUE, + seed = 1, + ... +)+ +
t1 | +filename (or nifti objects) of T1 image |
+
---|---|
t2 | +filename (or nifti objects) of T2 image |
+
register | +Register image to template file |
+
native | +If images are registered, should the native space +normalized image be returned? |
+
template.file | +Filename of template to warp to |
+
typeofTransform | +type of transformed used, passed to
+ |
+
interpolator | +Interpolation to be performed, passed to
+ |
+
type | +Type of whitestripe normalization done |
+
t1.outfile | +Output filename of normalized T1 image |
+
t2.outfile | +Output filename of normalized T2 image |
+
other.files | +Character filenames or list of nifti objects to +normalize. In the same space as T1. |
+
other.outfiles | +Character filenames for output +normalized files. |
+
ws.outfile | +Character filename for output +whitestripe mask. |
+
mask | +File or nifti image of brain mask |
+
mask.outfile | +Character filename for output +brain mask. |
+
verbose | +Print Diagnostic Messages |
+
reproducible | +Sets the seed and
+ |
+
seed | +will execute
+ |
+
... | +arguments to |
+
List of nifti objects or character filenames
+ +This function performs registration to a template
+using ANTsR and will run zscore_img
reg_zscore( + t1, + register = TRUE, + native = TRUE, + template.file = file.path(fsldir(), "data", "standard", paste0("MNI152_T1_1mm", + ifelse(is.null(mask), "", "_brain"), ".nii.gz")), + typeofTransform = c("Rigid", "Affine"), + interpolator = "LanczosWindowedSinc", + t1.outfile = NULL, + other.files = NULL, + other.outfiles = NULL, + mask = NULL, + mask.outfile = NULL, + verbose = TRUE, + reproducible = TRUE, + seed = 1, + ... +)+ +
t1 | +filename (or nifti objects) of T1 image |
+
---|---|
register | +Register image to template file |
+
native | +If images are registered, should the native space +normalized image be returned? |
+
template.file | +Filename of template to warp to |
+
typeofTransform | +type of transformed used, passed to
+ |
+
interpolator | +Interpolation to be performed, passed to
+ |
+
t1.outfile | +Output filename of normalized T1 image |
+
other.files | +Character filenames or list of nifti objects to +normalize. In the same space as T1. |
+
other.outfiles | +Character filenames for output +normalized files. |
+
mask | +File or nifti image of brain mask |
+
mask.outfile | +Character filename for output +brain mask. |
+
verbose | +Print Diagnostic Messages |
+
reproducible | +Sets the seed and
+ |
+
seed | +will execute
+ |
+
... | +arguments to |
+
List of nifti objects or character filenames
+ +This function performs registration +using ANTsR, carries out the transformation +on other images, and can back-transform image +in registered space to the native space of the original image. Returns the +transforms
+registration( + filename, + skull_strip = FALSE, + correct = FALSE, + correction = "N4", + retimg = TRUE, + outfile = NULL, + template.file = file.path(fsldir(), "data", "standard", "MNI152_T1_1mm_brain.nii.gz"), + interpolator = "Linear", + other_interpolator = interpolator, + other.files = NULL, + other.outfiles = NULL, + other.init = NULL, + invert_interpolator = interpolator, + invert.native.fname = NULL, + invert.file = NULL, + typeofTransform = "SyN", + remove.warp = FALSE, + outprefix = NULL, + bet.opts = "-B -f 0.1 -v", + betcmd = "bet", + copy_origin = TRUE, + verbose = TRUE, + reproducible = TRUE, + seed = 1, + force_registration = TRUE, + ... +)+ +
filename | +filename of image to be registered |
+
---|---|
skull_strip | +do skull stripping with FSL BET |
+
correct | +do bias correction on the filename |
+
correction | +N3 or N4 correction, see |
+
retimg | +return a nifti object from function |
+
outfile | +output filename should have .nii or .nii.gz +extension |
+
template.file | +Filename of image to warp to |
+
interpolator | +interpolation done for
+ |
+
other_interpolator | +interpolation done for
+ |
+
other.files | +Filenames of other iamges to be +transformed with the T1 |
+
other.outfiles | +Output filenames of |
+
other.init | +Initial transformation lists (same length as |
+
invert_interpolator | +interpolation done for
+ |
+
invert.native.fname | +filename of output native file, must have
+same length as |
+
invert.file | +Filename of image to invert to native space |
+
typeofTransform | +type of transformed used, passed to
+ |
+
remove.warp | +(logical) Should warping images be deleted? |
+
outprefix | +Character path of where the warp files should be stored.
+Required if |
+
bet.opts | +Options passed to |
+
betcmd | +BET command used, passed to |
+
copy_origin | +Copy image origin from t1, using |
+
verbose | +Print diagnostic messages |
+
reproducible | +Sets the seed and
+ |
+
seed | +will execute
+ |
+
force_registration | +If |
+
... | +arguments to |
+
List of the output filenames and transformations
+ +Removes the neck from axially acquired scan so +skull stripping can be done.
+remove_neck( + file, + template.file, + template.mask = NULL, + ret_mask = FALSE, + typeofTransform = "Rigid", + rep.value = 0, + swapdim = TRUE, + verbose = TRUE, + ... +)+ +
file | +File for neck removal - either filename or class nifti |
+
---|---|
template.file | +Template to warp to original image space |
+
template.mask | +Mask of template to use as rough brain mask. If
+ |
+
ret_mask | +Return mask of slices to keep |
+
typeofTransform | +Transformation for template to image, passed to
+ |
+
rep.value | +Value to replace neck slices with |
+
swapdim | +Should the dimensions be swapped before registration, +and then reset after |
+
verbose | +Print out diagnostic messages |
+
... | +Additional arguments passed to |
+
Object of class nifti or vector of indices
+ ++if (fslr::have.fsl()){ + print(fslr::fsl_version()) + in_ci <- function() { + nzchar(Sys.getenv("CI")) + } + if (in_ci()) { + destfile = tempfile(fileext = ".nii.gz") + dl = download.file(paste0( + "https://github.com/muschellij2/", + "Neurohacking/files/3454385/113-01-MPRAGE2.nii.gz"), + destfile = destfile) + tfile = fslr::mni_fname(brain = TRUE) + if (file.exists(tfile)) { + res = remove_neck( + destfile, + template.file = tfile, + template.mask = fslr::mni_fname(brain = TRUE, mask = TRUE) + ) + } + } +}#> [1] "5.0.10"
The output from getNeighborhoodInMask
gets reordered
+to match that which R uses for array to indices.
reorder_neigh_indices(indices, img.dim)+ +
indices | +Indices from |
+
---|---|
img.dim | +Image dimension from which neighborhood was taken |
+
List of new indices, the ordering, and a binary array which has a +1 where the indices are located
+ +R/reproducible_ants.R
+ reproducible_ants.Rd
Set reproducible seeds and threads for ANTsR execution
+reproducible_ants(seed = 1)+ +
seed | +will execute
+ |
+
---|
A list of `ANTS_RANDOM_SEED` and `ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS`
+See +https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues +for discussion.
+ ++reproducible_ants(1234)#> $ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS +#> [1] 1 +#> +#> $ANTS_RANDOM_SEED +#> [1] 1234 +#>
Resamples an antsImage
or
+nifti
+object
resample_image( + img, + parameters, + parameter_type = c("mm", "voxels"), + interpolator = c("nearestneighbor", "linear", "gaussian", "windowedsinc", "bspline"), + ... +) + +# S4 method for character +resample_image( + img, + parameters, + parameter_type = c("mm", "voxels"), + interpolator = c("nearestneighbor", "linear", "gaussian", "windowedsinc", "bspline"), + ... +) + +# S4 method for nifti +resample_image( + img, + parameters, + parameter_type = c("mm", "voxels"), + interpolator = c("nearestneighbor", "linear", "gaussian", "windowedsinc", "bspline"), + ... +) + +# S4 method for antsImage +resample_image( + img, + parameters, + parameter_type = c("mm", "voxels"), + interpolator = c("nearestneighbor", "linear", "gaussian", "windowedsinc", "bspline"), + ... +) + +.resample_image( + img, + parameters, + parameter_type = c("mm", "voxels"), + interpolator = c("nearestneighbor", "linear", "gaussian", "windowedsinc", "bspline") +)+ +
img | +character path of image or +an object of class nifti, or antsImage |
+
---|---|
parameters | +parameters
+to pass as |
+
parameter_type | +Are the parameters in units of +voxels or millimeters (mm) |
+
interpolator | +what type of interpolation should be +done |
+
... | +not currently used |
+
An antsImage
or nifti
depending on
+input
+library(oro.nifti) +library(extrantsr) +n = 30 +x = nifti(array(rnorm(n^3*10), dim = c(n, n, n))) +res = resample_image(x, parameters = c(0.5, 0.5, 0.5)) +res#> NIfTI-1 format +#> Type : nifti +#> Data Type : 16 (FLOAT32) +#> Bits per Pixel : 32 +#> Slice Code : 0 (Unknown) +#> Intent Code : 0 (None) +#> Qform Code : 1 (Scanner_Anat) +#> Sform Code : 0 (Unknown) +#> Dimension : 60 x 60 x 60 +#> Pixel Dimension : 0.5 x 0.5 x 0.5 +#> Voxel Units : mm +#> Time Units : Unknown
R/resample_to_target.R
+ resample_to_target-methods.Rd
Resamples an antsImage
or
+nifti
+object to a target
resample_to_target( + img, + target, + interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline", + "cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc", + "lanczosWindowedSinc", "genericLabel"), + copy_origin = FALSE, + ... +) + +# S4 method for character +resample_to_target( + img, + target, + interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline", + "cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc", + "lanczosWindowedSinc", "genericLabel"), + copy_origin = FALSE, + ... +) + +# S4 method for nifti +resample_to_target( + img, + target, + interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline", + "cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc", + "lanczosWindowedSinc", "genericLabel"), + copy_origin = FALSE, + ... +) + +# S4 method for antsImage +resample_to_target( + img, + target, + interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline", + "cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc", + "lanczosWindowedSinc", "genericLabel"), + copy_origin = FALSE, + ... +) + +.resample_to_target( + img, + target, + interpolator = c("linear", "nearestNeighbor", "multiLabel", "gaussian", "bSpline", + "cosineWindowedSinc", "welchWindowedSinc", "hammingWindowedSinc", + "lanczosWindowedSinc", "genericLabel"), + copy_origin = FALSE, + ... +)+ +
img | +character path of image or +an object of class nifti, or antsImage |
+
---|---|
target | +image of reference,
+the output will be in this space.
+Will be coerced using |
+
interpolator | +what type of interpolation should be +done |
+
copy_origin | +Copy image origin from |
+
... | +additional arguments to pass to
+ |
+
An antsImage
or nifti
depending on
+input
+library(oro.nifti) +library(extrantsr) +n = 30 +x = nifti(array(rnorm(n^3*10), dim = c(n, n, n))) +new_pixdim = c(0.5, 0.5, 0.5) +res = resample_image(x, parameters = new_pixdim) +x2 = resample_to_target(x, res) +pixdim(x2)[2:4]#> [1] 0.5 0.5 0.5
Masks the brain from scan using a rigid body transformation +of the template mask to the native brain space and then inflating the mask +to adjust for mis-registration.
+robust_brain_mask( + file, + template.file, + template.mask = NULL, + nvoxels = 7, + ret_mask = FALSE, + typeofTransform = "Rigid", + verbose = TRUE, + ... +)+ +
file | +File for masking - either filename or class nifti |
+
---|---|
template.file | +Template to warp to original image space |
+
template.mask | +Mask of template to use as rough brain mask. If
+ |
+
nvoxels | +Number of voxels in nxnxn direction to inflate, see
+ |
+
ret_mask | +Return mask of robust brain |
+
typeofTransform | +Transformation for template to image, passed to
+ |
+
verbose | +Print diagnostic progress |
+
... | +Arguments passed to |
+
Object of class nifti or vector of indices
+ +R/scaled_neighborhood.R
+ scaled_neighborhood.Rd
This function wraps the neighborhood
to
+provided scaled neighborhood or its ranks
scaled_neighborhood( + img, + mask = NULL, + radius = rep(1, 3), + method = c("pearson", "spearman"), + center = TRUE, + scale = TRUE, + verbose = TRUE +)+ +
img | +Object of class |
+
---|---|
mask | +Binary image of class |
+
radius | +vector of length 3 for number of voxels to go in each direction.
+Default is 27 neighbors (including voxel at center).
+Passed to |
+
method | +If pearson, scaling done on original data. If spearman, +the ranks. |
+
center | +Should the data be centered |
+
scale | +Should the data be scaled |
+
verbose | +print diagnostic messages |
+
List similar to the output of getNeighborhoodInMask
This function calls smoothIamge
to smooth an image and either
+saves the image or returns an object of class nifti
smooth_image( + file, + sigma = 10, + mask = NULL, + smooth_mask = TRUE, + smoothed_mask = NULL, + verbose = TRUE, + retfile = FALSE, + ... +)+ +
file | +(character) image to be smoothed |
+
---|---|
sigma | +(numeric) sigma (in mm) of Gaussian kernel for smoothing |
+
mask | +(character) optional mask given for image |
+
smooth_mask | +(logical) Smooth mask? If TRUE, the masked image +will be divided by the smoothed mask. |
+
smoothed_mask | +(character or antsImage) If specified and
+ |
+
verbose | +(logical) print out command before running |
+
retfile | +logical to indicate if an |
+
... | +additional arguments passed to |
+
Object of class nifti
+system.time({ +library(oro.nifti) +dims = c(50, 50, 50) +x = array(rnorm(prod(dims)), dim = dims) +img = nifti(x, dim= dims, +datatype = convert.datatype()$FLOAT32, cal.min = min(x), +cal.max = max(x), pixdim = rep(1, 4)) +s.img = smooth_image(img, sigma = 3, sigmaInPhysicalCoordinates = TRUE) +})#> user system elapsed +#> 0.839 0.029 1.010
This function performs robust skull stripping on the +T1, then preprocessing within visit
+smri_preproc( + files, + window = FALSE, + outfiles = NULL, + maskfile = NULL, + correct = TRUE, + correction = "N4", + correct_after_mask = TRUE, + verbose = TRUE, + ... +)+ +
files | +filenames (or nifti objects) of images to be processed. +Will register to the first scan |
+
---|---|
window | +Should |
+
outfiles | +(character) name of output files, with extension |
+
maskfile | +Filename (or nifti object) of mask for image to be +registered to |
+
correct | +do Bias field correction |
+
correction | +(character) N3 or N4 correction? |
+
correct_after_mask | +Should the inhomogeneity correction be run +after masking. |
+
verbose | +Diagnostic messages |
+
... | +arguments to |
+
List from preprocess_mri_within
This function wraps fslbet
and
+bias_correct
, performing skull stripping first
ss_bias( + filename, + maskfile = NULL, + outfile = tempfile(fileext = ".nii.gz"), + skull_strip = TRUE, + bet.opts = "", + betcmd = "bet", + correct = TRUE, + correction = "N3", + shrinkfactor = "4", + retimg = TRUE, + reorient = FALSE, + verbose = TRUE, + ... +)+ +
filename | +filename to be processed |
+
---|---|
maskfile | +filename of masked to be passed in, otherwise bet is performed |
+
outfile | +output filename with extension (e.g. |
+
skull_strip | +should skull stripping be done |
+
bet.opts | +options for fslbet |
+
betcmd | +bet command to be used see |
+
correct | +should n3 correction be done stripping be done |
+
correction | +correction method used see |
+
shrinkfactor | +correction method used see |
+
retimg | +(logical) return image of class nifti |
+
reorient | +(logical) If retimg, should file be reoriented when read in?
+Passed to |
+
verbose | +Diagnostic output |
+
... | +passed to |
+
Filename of output file or object of class nifti
+Creates output from a list of images, performing voxel-wise +operations to create a statistic image
+stat_img( + imgs, + func = c("mean", "median", "mode", "pct", "peak", "sd", "var", "mad", "sum", "prod", + "z", "quantile", "staple_prob", "staple_label"), + finite = TRUE, + masks = NULL, + na_masks = TRUE, + ... +)+ +
imgs | +Character vector, list of characters, or object of class
+ |
+
---|---|
func | +Function to perform voxel-wise on list of images |
+
finite | +Should non-finite values be removed? |
+
masks | +Character vector, list of characters, or object of class
+ |
+
na_masks | +if |
+
... | +Addictional arguments to pass to |
+
Object of class nifti
When func = "mode"
, the data is tabulated and then
+max.col
is run. The user can pass ties.method
to
+determine how to break ties. The default is "first"
as compared to
+max.col
where it is "random"
. When func = "peak"
,
+density
is run on each voxel and the value with the maximum. If
+the number of unique values is only 1, that value is returned.
Subsets an antsImage
or nifti
+object from 4D
subset_4d(img, ind, ...) + +# S4 method for character +subset_4d(img, ind, ...) + +# S4 method for nifti +subset_4d(img, ind, ...) + +# S4 method for antsImage +subset_4d(img, ind, ...) + +.subset_4d(img, ind)+ +
img | +character path of image or +an object of class nifti, or antsImage |
+
---|---|
ind | +subset indexers for the 4th dimension (usually time) |
+
... | +Arguments passed to |
+
An antsImage
or nifti
depending on
+input
+library(oro.nifti) +n = 20 +x = nifti(array(rnorm(n^3*10), dim = c(n, n, n, 10))) +ind = 2:3 +subset_4d(x, ind)#> NIfTI-1 format +#> Type : nifti +#> Data Type : 2 (UINT8) +#> Bits per Pixel : 8 +#> Slice Code : 0 (Unknown) +#> Intent Code : 0 (None) +#> Qform Code : 0 (Unknown) +#> Sform Code : 0 (Unknown) +#> Dimension : 20 x 20 x 20 x 2 +#> Pixel Dimension : 1 x 1 x 1 x 1 +#> Voxel Units : Unknown +#> Time Units : Unknownsubset_4d(x, ind = 1)#> NIfTI-1 format +#> Type : nifti +#> Data Type : 2 (UINT8) +#> Bits per Pixel : 8 +#> Slice Code : 0 (Unknown) +#> Intent Code : 0 (None) +#> Qform Code : 0 (Unknown) +#> Sform Code : 0 (Unknown) +#> Dimension : 20 x 20 x 20 +#> Pixel Dimension : 1 x 1 x 1 +#> Voxel Units : Unknown +#> Time Units : Unknown
Takes in a object of class antsImage
,
+writes it to a temp file, and appends .nii or .nii.gz
tempants(x, gzipped = TRUE, ...)+ +
x | +object of class |
+
---|---|
gzipped | +logical if the tempfile should be gzipped or not |
+
... | +additional arguments to pass to |
+
Character value of filename
+ +R/transformlist_from_outprefix.R
+ transformlist_from_outprefix.Rd
Get list of transforms that would likely be made with a specific `outprefix`
+transformlist_from_outprefix( + outprefix, + typeofTransform = "SyN", + only_exists = FALSE +)+ +
outprefix | +If you used this in |
+
---|---|
typeofTransform | +transformation to be used in registration |
+
only_exists | +if |
+
A list of character vectors
+ ++#> $fwdtransforms +#> [1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpZAwKcw/file78c84ac27a3d1Warp.nii.gz" +#> [2] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpZAwKcw/file78c84ac27a3d0GenericAffine.mat" +#> +#> $invtransforms +#> [1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpZAwKcw/file78c84ac27a3d0GenericAffine.mat" +#> [2] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpZAwKcw/file78c84ac27a3d1InverseWarp.nii.gz" +#>transformlist_from_outprefix(outprefix, typeofTransform = "Rigid")#> $fwdtransforms +#> [1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpZAwKcw/file78c84ac27a3d0GenericAffine.mat" +#> +#> $invtransforms +#> [1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpZAwKcw/file78c84ac27a3d0GenericAffine.mat" +#>
R/within_visit_registration.R
+ within_visit_registration.Rd
This function performs registration to a T1 template +using ANTsR and SyN transformation
+within_visit_registration( + fixed, + moving, + outfiles = NULL, + typeofTransform = "Rigid", + interpolator = "Linear", + ... +)+ +
fixed | +filename of fixed image to be registered to. |
+
---|---|
moving | +filenames (or nifti) of images to register to fixed image |
+
outfiles | +Output filenames, same length as moving |
+
typeofTransform | +Transformation of moving to fixed image |
+
interpolator | +Interpolation to be done |
+
... | +additional arguments to |
+
List of results from registration
Zero pads an image
+zero_pad(img, ...)+ +
img | +Array, class |
+
---|---|
... | +Options to |
+
Object of class nifti, array, or antsImage
Registers an image to a template, subtracts a mean and sd image, and +will return the image either in template space or native.
+zscore_template( + img, + template.file, + mean.img, + sd.img, + outfile = NULL, + typeofTransform = "SyN", + interpolator = "Linear", + robust = TRUE, + probs = c(0, 0.999), + native = TRUE, + verbose = TRUE, + ... +)+ +
img | +Image to be z-scored |
+
---|---|
template.file | +Template file to be registered to. An affine registration +will be done usually, so if the image is skull-stripped, use a skull-stripped +template and vice versa |
+
mean.img | +Mean image to be subtracted |
+
sd.img | +SD image to be divded |
+
outfile | +Output filename. Will use |
+
typeofTransform | +Transform for registration. See |
+
interpolator | +Interpolator to use, See |
+
robust | +Should See |
+
probs | +quantiles to constrain the image these define the window sent
+to |
+
native | +Should a native-space image (default) or template-space image +be returned |
+
verbose | +Print diagnostic output |
+
... | +Options passed to |
+
Object of class nifti