From c07c659db20ed5fed12f40c970202efc730d79b5 Mon Sep 17 00:00:00 2001 From: Biafra Ahanonu Date: Thu, 22 Jul 2021 19:53:45 -0700 Subject: [PATCH 1/5] Move functions into ciapkg package. --- {ciapkg/_overloaded => +ciapkg/+overloaded}/ginputCustom.m | 0 .../_overloaded/msgbox_custom.m => +ciapkg/+overloaded/msgbox.m | 0 .../+overloaded}/private/dialogCellstrHelper.m | 0 .../+overloaded}/private/getnicedialoglocation.m | 0 .../+overloaded}/private/setdefaultbutton.m | 0 {ciapkg/_overloaded => +ciapkg/+overloaded}/subplot.m | 0 {ciapkg/_overloaded => +ciapkg/+overloaded}/suptitle.m | 0 loadBatchFxns.m => +ciapkg/loadBatchFxns.m | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename {ciapkg/_overloaded => +ciapkg/+overloaded}/ginputCustom.m (100%) rename ciapkg/_overloaded/msgbox_custom.m => +ciapkg/+overloaded/msgbox.m (100%) rename {ciapkg/_overloaded => +ciapkg/+overloaded}/private/dialogCellstrHelper.m (100%) rename {ciapkg/_overloaded => +ciapkg/+overloaded}/private/getnicedialoglocation.m (100%) rename {ciapkg/_overloaded => +ciapkg/+overloaded}/private/setdefaultbutton.m (100%) rename {ciapkg/_overloaded => +ciapkg/+overloaded}/subplot.m (100%) rename {ciapkg/_overloaded => +ciapkg/+overloaded}/suptitle.m (100%) rename loadBatchFxns.m => +ciapkg/loadBatchFxns.m (100%) diff --git a/ciapkg/_overloaded/ginputCustom.m b/+ciapkg/+overloaded/ginputCustom.m similarity index 100% rename from ciapkg/_overloaded/ginputCustom.m rename to +ciapkg/+overloaded/ginputCustom.m diff --git a/ciapkg/_overloaded/msgbox_custom.m b/+ciapkg/+overloaded/msgbox.m similarity index 100% rename from ciapkg/_overloaded/msgbox_custom.m rename to +ciapkg/+overloaded/msgbox.m diff --git a/ciapkg/_overloaded/private/dialogCellstrHelper.m b/+ciapkg/+overloaded/private/dialogCellstrHelper.m similarity index 100% rename from ciapkg/_overloaded/private/dialogCellstrHelper.m rename to +ciapkg/+overloaded/private/dialogCellstrHelper.m diff --git a/ciapkg/_overloaded/private/getnicedialoglocation.m b/+ciapkg/+overloaded/private/getnicedialoglocation.m similarity index 100% rename from ciapkg/_overloaded/private/getnicedialoglocation.m rename to +ciapkg/+overloaded/private/getnicedialoglocation.m diff --git a/ciapkg/_overloaded/private/setdefaultbutton.m b/+ciapkg/+overloaded/private/setdefaultbutton.m similarity index 100% rename from ciapkg/_overloaded/private/setdefaultbutton.m rename to +ciapkg/+overloaded/private/setdefaultbutton.m diff --git a/ciapkg/_overloaded/subplot.m b/+ciapkg/+overloaded/subplot.m similarity index 100% rename from ciapkg/_overloaded/subplot.m rename to +ciapkg/+overloaded/subplot.m diff --git a/ciapkg/_overloaded/suptitle.m b/+ciapkg/+overloaded/suptitle.m similarity index 100% rename from ciapkg/_overloaded/suptitle.m rename to +ciapkg/+overloaded/suptitle.m diff --git a/loadBatchFxns.m b/+ciapkg/loadBatchFxns.m similarity index 100% rename from loadBatchFxns.m rename to +ciapkg/loadBatchFxns.m From b33247f9396836068b86eb523dae7f5d90cae3b1 Mon Sep 17 00:00:00 2001 From: Biafra Ahanonu Date: Sun, 25 Jul 2021 14:20:11 -0700 Subject: [PATCH 2/5] Updated to MIT license from GPL-3.0 License --- LICENSE | 695 ++---------------------------------------------------- README.md | 13 +- 2 files changed, 26 insertions(+), 682 deletions(-) diff --git a/LICENSE b/LICENSE index 339e785..de653d9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +1,21 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - 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. - - CIAtah (pronounced cheetah) or calciumImagingAnalysis (ciapkg): a software package for calcium imaging analysis of one- and two-photon imaging datasets. - Copyright (C) 2020 Biafra Ahanonu - - 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 . - -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: - - CIAtah (calciumImagingAnalysis) Copyright (C) 2020 Biafra Ahanonu - 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 -. - - 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 -. +MIT License + +Copyright (C) 2013-2021 Biafra Ahanonu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 2eb6aa3..27ad6ea 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@
-`CIAtah` (pronounced cheetah; formerly calciumImagingAnalysis [ciapkg]) is a software package for analyzing one- and two-photon calcium imaging datasets. +`CIAtah` (pronounced cheetah; formerly calciumImagingAnalysis [ciapkg]) is a software package for analyzing one- and two-photon calcium imaging datasets. + +Currently requires `MATLAB` and runs on all major operating systems (Windows, Linux [e.g. Ubuntu], and macOS). ## Full documentation at https://bahanonu.github.io/ciatah/. @@ -68,7 +70,7 @@ Made in USA.
- Supports a plethora of major imaging movie file formats: HDF5, NWB, AVI, ISXD [Inscopix], TIFF, and [Bio-Formats](https://www.openmicroscopy.org/bio-formats/) compatible formats (Olympus [OIR] and Zeiss [CZI and LSM] currently, additional support to be added or upon request). - Supports [Neurodata Without Borders](https://www.nwb.org/) data standard (see [calcium imaging tutorial](https://neurodatawithoutborders.github.io/matnwb/tutorials/html/ophys.html)) for reading/writing cell-extraction and imaging movie files. - Animal position tracking (e.g. in open-field assay). -- Requires `MATLAB`. +- Requires `MATLAB` and runs on all major operating systems (Windows, Linux [e.g. Ubuntu], and macOS). ## CIAtah example features @@ -250,12 +252,7 @@ Please email any additional questions not covered in the repository to `github [ Copyright (C) 2013-2021 Biafra Ahanonu -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 . +This project is licensed under the terms of the MIT license. ## Repository stats - ![visitors](https://visitor-badge.glitch.me/badge?page_id=bahanonu.calciumImagingAnalysis) (starting 2020.09.22) From 22aff9237b2685a0dabeea8a7312390aa0d79489 Mon Sep 17 00:00:00 2001 From: Biafra Ahanonu Date: Sun, 25 Jul 2021 14:36:25 -0700 Subject: [PATCH 3/5] Overload moving, signalSorter, detrend, and misc. other updates. Main features and changes: - Changed license to MIT. - Added detrend support for `ciatah` class modelPreprocessMovieFunction. - Moved `ciapkg` overloaded functions into sub-package `ciapkg.overloaded` to clean up namespace and not interfere with users namespace, updated dependent functions accordingly. - Moved `loadBatchFxns` into `ciapkg` package and updated all functions accordingly. - Speed improvements when setting up `ciatah` class. ## New functions - None. ## Updated `@ciatah` - `ciatahMainGui` - Update to improve handling of output variables when figure closes to avoid calling invalid handles. - `computeCellDistances` - Added gramm plots that show the distribution of cell-cell distances. - `getRegistrationSettings` - Added support for certain options (e.g. motion correction) to give a vector and also added movie detrend options. - `modelPreprocessMovieFunction` - Add support for multiple reference frames, the mean is taken before input to motion correction. Added support for detrending movies. ## Updated `ciapkg` - `signalSorter` - Changed call to overloaded functions to `ciapkg.overloaded` to avoid altering users Matlab workspace native functions. Change selection of cell on the maps to be instantaneous for where the mouse location is, much faster, don't have to wait for ginputCustom cross-hairs to show. Users can still show crosshairs with 'V'. - `thresholdImages` - Fast border calculation using convn for options.fastThresholding==1, less precise than bwboundaries or bwareafilt but works for fast display purposes. - `manageMiji` - Check that ImageJ already in java path to prevent duplicate loading and wasting time. ## Updated `+ciapkg` - `loadBatchFxns` - Remove redundant loading and unloading of external programs via additional checks. Moved loadBatchFxns into ciapkg package. Use ciapkg.getDir to get directory as standard IO. --- +ciapkg/+demo/cmdLinePipeline.m | 6 +- +ciapkg/+download/updatePathCleanup.m | 2 +- +ciapkg/+io/loadDependencies.m | 17 ++++- +ciapkg/+io/updatePkg.m | 4 +- +ciapkg/VERSION | 4 +- +ciapkg/loadAllDirs.m | 2 +- +ciapkg/loadBatchFxns.m | 44 +++++++++--- +ciapkg/loadDirs.m | 2 +- @ciatah/ciatahMainGui.m | 58 ++++++++++----- @ciatah/computeCellDistances.m | 57 ++++++++++++++- @ciatah/getRegistrationSettings.m | 40 +++++++++-- @ciatah/help.m | 2 +- @ciatah/initializeObj.m | 2 +- @ciatah/loadBatchFunctionFolders.m | 2 +- @ciatah/modelExtractSignalsFromMovie.m | 4 +- @ciatah/modelGetSignalsImages.m | 7 ++ @ciatah/modelModifyMovies.m | 2 +- @ciatah/modelModifyRegionAnalysis.m | 4 +- @ciatah/modelPreprocessMovie.m | 2 +- @ciatah/modelPreprocessMovieFunction.m | 71 ++++++++++++++++--- @ciatah/modelVarsFromFilesCheck.m | 3 + @ciatah/modelVerifyDataIntegrity.m | 2 +- @ciatah/pipelineListBox.m | 2 +- @ciatah/runPipeline.m | 4 +- @ciatah/setup.m | 2 +- @ciatah/update.m | 2 +- @ciatah/viewCellExtractionOnMovie.m | 8 +-- @ciatah/viewCreateObjmaps.m | 6 +- @ciatah/viewMatchObjBtwnSessions.m | 2 +- @ciatah/viewMovie.m | 4 +- @ciatah/viewMovieRegistrationTest.m | 8 +-- @ciatah/viewObjmaps.m | 6 +- @ciatah/viewSubjectMovieFrames.m | 8 +-- ciapkg/classification/signalSorter.m | 24 ++++++- ciapkg/download/downloadMiji.m | 2 +- ciapkg/image/thresholdImages.m | 33 ++++++--- ciapkg/io/loadMovieList.m | 6 +- ciapkg/io/manageMiji.m | 29 ++++++-- .../computeManualMotionCorrection.m | 2 + ciapkg/neighbor/viewNeighborsAuto.m | 2 +- ciapkg/signal_processing/computeSignalPeaks.m | 2 +- ciapkg/tracking/removeIncorrectObjs.m | 4 +- ciapkg/view/playMovie.m | 12 ++-- docs/docs/help_analysis_methods.md | 5 ++ docs/docs/help_cross_session_alignment.md | 45 ++++++++++-- docs/docs/index.md | 2 + docs/docs/pipeline_detailed_cross_session.md | 54 ++++++++++++-- docs/docs/pipeline_detailed_preprocess.md | 1 + startup.m | 6 +- 49 files changed, 481 insertions(+), 137 deletions(-) diff --git a/+ciapkg/+demo/cmdLinePipeline.m b/+ciapkg/+demo/cmdLinePipeline.m index 9e0ed70..0e26c73 100644 --- a/+ciapkg/+demo/cmdLinePipeline.m +++ b/+ciapkg/+demo/cmdLinePipeline.m @@ -27,7 +27,7 @@ nwbFileFolderPath = [analysisFolderPath filesep 'nwbFiles']; % Load CIAtah functions -loadBatchFxns(); +ciapkg.loadBatchFxns(); % ================================================= %% Download test data, only a single session @@ -166,7 +166,7 @@ % ================================================= %% Run EXTRACT cell extraction. Check each function with "edit" for options. % Load default configuration -loadBatchFxns('loadEverything'); +ciapkg.loadBatchFxns('loadEverything'); extractConfig = get_defaults([]); % See https://github.com/schnitzer-lab/EXTRACT-public#configurations. @@ -196,7 +196,7 @@ end % Remove EXTRACT from the path. -loadBatchFxns(); +ciapkg.loadBatchFxns(); % ================================================= %% USER INTERFACE Run cell sorting using matrix outputs from cell extraction. diff --git a/+ciapkg/+download/updatePathCleanup.m b/+ciapkg/+download/updatePathCleanup.m index d917c4f..3b60132 100644 --- a/+ciapkg/+download/updatePathCleanup.m +++ b/+ciapkg/+download/updatePathCleanup.m @@ -36,7 +36,7 @@ % Remove references to MEX files clear mex - loadBatchFxns('excludeExternalPrograms'); + ciapkg.loadBatchFxns('excludeExternalPrograms'); pathCell = regexp(path, pathsep, 'split'); if verLessThan('matlab','9.1') diff --git a/+ciapkg/+io/loadDependencies.m b/+ciapkg/+io/loadDependencies.m index 0f0495c..690ddd2 100644 --- a/+ciapkg/+io/loadDependencies.m +++ b/+ciapkg/+io/loadDependencies.m @@ -19,6 +19,7 @@ function loadDependencies(varargin) % 2021.06.19 [23:46:58] - Switched to support for original MIJ calling of ImageJ using just jar files, easier compatibility across MATLAB versions and OSes. % 2021.06.21 [16:45:59] - Update order. % 2021.07.13 [08:34:18] - Added backup URL for downloading mij.jar. + % 2021.07.23 [00:22:22] - Added gramm. % TODO % Verify all dependencies download and if not ask user to download again. @@ -26,11 +27,11 @@ function loadDependencies(varargin) % DESCRIPTION options.externalProgramsDir = ciapkg.getDirExternalPrograms(); options.guiEnabled = 1; - options.dependencyStr = {'downloadImageJ','downloadCnmfGithubRepositories','example_downloadTestData','downloadNeuroDataWithoutBorders','downloadEXTRACT','downloadBioFormats','downloadNoRMCorre','downloadMiji','loadMiji'}; + options.dependencyStr = {'downloadImageJ','downloadCnmfGithubRepositories','example_downloadTestData','downloadNeuroDataWithoutBorders','downloadEXTRACT','downloadBioFormats','downloadGramm','downloadNoRMCorre','downloadMiji','loadMiji'}; - options.dispStr = {'Download ImageJ','Download CNMF, CNMF-E, and CVX code.','Download test one- and two photon datasets.','Download NWB (NeuroDataWithoutBorders)','Download EXTRACT','Download Bio-Formats','Download NoRMCorre (motion correction)','Download Fiji (to run Miji)','Load Fiji/Miji into MATLAB path.'}; + options.dispStr = {'Download ImageJ','Download CNMF, CNMF-E, and CVX code.','Download test one- and two photon datasets.','Download NWB (NeuroDataWithoutBorders)','Download EXTRACT','Download Bio-Formats','Download gramm (GRAMmar of graphics for Matlab, e.g. ggplot2-like)','Download NoRMCorre (motion correction)','Download Fiji (to run Miji)','Load Fiji/Miji into MATLAB path.'}; % Int vector: index of options.dependencyStr to run by default with no GUI - options.depIdxArray = [1 2 3 4 5 6]; + options.depIdxArray = [1 2 3 4 5 6 7]; % Binary: 1 = force update even if already downloaded. 0 = skip if already downloaded options.forceUpdate = 0; % get options @@ -109,6 +110,16 @@ function loadDependencies(varargin) % optionsH.gitName = cellfun(@(x) [x '-master'],optionsH.gitNameDisp,'UniformOutput',false); optionsH.gitName = {'NoRMCorre-public-master'}; [success] = downloadGithubRepositories('options',optionsH); + case 'downloadGramm' + optionsH.forceUpdate = forceUpdate; + optionsH.signalExtractionDir = options.externalProgramsDir; + optionsH.gitNameDisp = {'gramm'}; + optionsH.gitRepos = {'https://github.com/piermorel/gramm'}; + optionsH.gitRepos = cellfun(@(x) [x '/archive/master.zip'],optionsH.gitRepos,'UniformOutput',false); + optionsH.outputDir = optionsH.gitNameDisp; + % optionsH.gitName = cellfun(@(x) [x '-master'],optionsH.gitNameDisp,'UniformOutput',false); + optionsH.gitName = {'gramm-master'}; + [success] = downloadGithubRepositories('options',optionsH); case 'downloadEXTRACT' optionsH.forceUpdate = forceUpdate; optionsH.signalExtractionDir = options.externalProgramsDir; diff --git a/+ciapkg/+io/updatePkg.m b/+ciapkg/+io/updatePkg.m index e3950d0..15fe6d7 100644 --- a/+ciapkg/+io/updatePkg.m +++ b/+ciapkg/+io/updatePkg.m @@ -79,7 +79,7 @@ verInfoStr = sprintf('%s\n Local version: %s (%s).\n Online version %s (%s).\n',verInfoStr2,currentVersion,currentDateTimeStr,onlineVersionTmp,onlineDateTimeStr); warning(verInfoStr) if verCompare<1 - msgbox(verInfoStr,'Note on CIAtah version.') + ciapkg.overloaded.msgbox(verInfoStr,'Note on CIAtah version.') end success = 1; return @@ -87,7 +87,7 @@ disp(verInfoStr) if options.showGui==1 - uiwait(msgbox(verInfoStr)); + uiwait(ciapkg.overloaded.msgbox(verInfoStr)); end % If the user is behind, ask if they want to update then initiate download and update from online repository diff --git a/+ciapkg/VERSION b/+ciapkg/VERSION index 7cc7afb..877faa1 100644 --- a/+ciapkg/VERSION +++ b/+ciapkg/VERSION @@ -1,2 +1,2 @@ -v3.33.0 -2021.07.13 [13:22:16] \ No newline at end of file +v3.35.1 +2021.07.25 [14:22:59] \ No newline at end of file diff --git a/+ciapkg/loadAllDirs.m b/+ciapkg/loadAllDirs.m index e76c350..9252012 100644 --- a/+ciapkg/loadAllDirs.m +++ b/+ciapkg/loadAllDirs.m @@ -26,7 +26,7 @@ function loadAllDirs() %======================== try - loadBatchFxns('loadEverything'); + ciapkg.loadBatchFxns('loadEverything'); catch err disp(repmat('@',1,7)) disp(getReport(err,'extended','hyperlinks','on')); diff --git a/+ciapkg/loadBatchFxns.m b/+ciapkg/loadBatchFxns.m index 975d8c4..372b507 100644 --- a/+ciapkg/loadBatchFxns.m +++ b/+ciapkg/loadBatchFxns.m @@ -22,6 +22,8 @@ function loadBatchFxns(varargin) % 2020.07.21 [14:11:42] - Fix to make sure all sub-folders (not just the root) are also removed in the case of certain external_programs. % 2021.02.01 [‏‎15:19:40] - Update `_external_programs` to call ciapkg.getDirExternalPrograms() to standardize call across all functions. % 2021.06.20 [00:22:38] - Added manageMiji('startStop','closeAllWindows'); support. + % 2021.07.16 [13:38:55] - Remove redundant loading and unloading of external programs via additional checks. + % 2021.07.22 [19:51:50] - Moved loadBatchFxns into ciapkg package. Use ciapkg.getDir to get directory as standard IO. % TODO % @@ -30,10 +32,14 @@ function loadBatchFxns(varargin) externalProgramsDir = ciapkg.getDirExternalPrograms(); + removeDirFxnToFind = {'runCELLMax.m','extractor.m','normcorre.m'}; + % 'cellmax.runCELLMax', 'CELLMax_Wrapper.m' + % Add calciumImagingAnalysis directory and subdirectories to path, use dbstack to ensure only add in the root directory regardless of where user has current MATLAB folder. - functionLocation = dbstack('-completenames'); - functionLocation = functionLocation(1).file; - [functionDir,~,~] = fileparts(functionLocation); + % functionLocation = dbstack('-completenames'); + % functionLocation = functionLocation(1).file; + % [functionDir,~,~] = fileparts(functionLocation); + functionDir = ciapkg.getDir; pathList = genpath(functionDir); % pathList = genpath(pwd); pathListArray = strsplit(pathList,pathsep); @@ -66,8 +72,16 @@ function loadBatchFxns(varargin) pathListArray = pathListArray(~pathFilter); pathFilter = ismember(pathListArray,strsplit(path,pathsep)); pathListArray = pathListArray(~pathFilter); + + % If going to remove directories in removeDirFxnToFind then do so now to prevent redundant calls to addpath, etc. + if isempty(varargin) + [pathListArray] = subfxnRemoveDirs(0,pathListArray); + end + + skipRemovePath = 0; if isempty(pathListArray) fprintf('MATALB path already has all needed non-private folders under: %s\n',functionDir); + skipRemovePath = 1; else fprintf('Adding all non-private folders under: %s\n',functionDir); pathList = strjoin(pathListArray,pathsep); @@ -84,7 +98,9 @@ function loadBatchFxns(varargin) matchIdx2 = contains(pathListArray,externalProgramsDir); pathListArray = pathListArray(~matchIdx2); else - pathListArray = subfxnRemoveDirs(1,pathListArrayOriginal); + if skipRemovePath==0 + pathListArray = subfxnRemoveDirs(1,pathListArrayOriginal); + end end % ================================================= @@ -203,23 +219,27 @@ function loadBatchFxns(varargin) % ================================================= % List of functions in root of external program directories that should not be included by default. try - fxnRootFolder = {'CELLMax_Wrapper.m','cellmax.runCELLMax','extractor.m','normcorre.m'}; + fxnRootFolder = removeDirFxnToFind; pathToRmCell = {}; for iNo = 1:length(fxnRootFolder) thisFxn = fxnRootFolder{iNo}; if rmPathFlag==1 [pathToRm,~,~] = fileparts(which(thisFxn)); else - extDir = dir([functionDir filesep externalProgramsDir]); + % extDir = dir([functionDir filesep externalProgramsDir]); + extDir = dir([externalProgramsDir]); extDir = extDir([extDir.isdir]); if length(extDir)<3 disp('No external programs!') return; end extDir = extDir(3:end); - - foundFiles = dir(fullfile([functionDir filesep externalProgramsDir], ['**\' thisFxn ''])); - pathToRm = foundFiles.folder; + foundFiles = dir(fullfile([externalProgramsDir], ['**\' thisFxn ''])); + if isempty(foundFiles) + pathToRm = []; + else + pathToRm = foundFiles.folder; + end end if ~isempty(pathToRm) if strcmp(thisFxn,'CELLMax_Wrapper.m')|strcmp(thisFxn,'cellmax.runCELLMax') @@ -246,8 +266,10 @@ function loadBatchFxns(varargin) end end - % - rmpath(strjoin(pathToRmCell,pathsep)); + % Only remove path if user requests + if rmPathFlag==1 + rmpath(strjoin(pathToRmCell,pathsep)); + end catch err disp(repmat('@',1,7)) disp(getReport(err,'extended','hyperlinks','on')); diff --git a/+ciapkg/loadDirs.m b/+ciapkg/loadDirs.m index 352d7af..ad81e4a 100644 --- a/+ciapkg/loadDirs.m +++ b/+ciapkg/loadDirs.m @@ -26,7 +26,7 @@ function loadDirs() %======================== try - loadBatchFxns; + ciapkg.loadBatchFxns; catch err disp(repmat('@',1,7)) disp(getReport(err,'extended','hyperlinks','on')); diff --git a/@ciatah/ciatahMainGui.m b/@ciatah/ciatahMainGui.m index 9fad9b1..7793fde 100644 --- a/@ciatah/ciatahMainGui.m +++ b/@ciatah/ciatahMainGui.m @@ -17,6 +17,7 @@ % 2021.07.06 [11:33:22] - Cell extraction now thresholded for cleaner visuals. % 2021.07.07 [17:26:20] - Add sliders to allow users to quickly scroll through both movies. % 2021.07.13 [13:18:45] - Updated to ensure movie callback playback loop operations only occur if handles to movies are still valid, e.g. if main GUI figure is still open. + % 2021.07.20 [13:43:50] - Update to improve handling of output variables when figure closes to avoid calling invalid handles. % TODO % @@ -41,9 +42,13 @@ % Binary: 1 = run method, 0 = skip running methods startMethodFlag = 0; + % Output structure + hListboxStruct = []; + % Use to stop the current movie looping breakMovieLoop = 0; - enableMoviePreview = 1; + % Binary: 1 = enable preview of movies, 0 = do not preview movies + enableMoviePreview = 0; movieImgHandle = plot([],[],'-'); movieAxes = plot([],[],'-'); titleHandle = plot([],[],'-'); @@ -185,18 +190,12 @@ [runMoviesToggleHandle, fileFilterRegexpHandle, fileFilterRegexpRawHandle, FRAMES_PER_SECONDHandle, inputDatasetNameHandle] = subfxn_movieOptionsCreate(); - %% ========================================== % FINAL SETUP figure(hFig) uicontrol(hListbox) % set(hFig, 'KeyPressFcn', @(src,event) onFigKeyPress(src,event,hListboxS)); - hListboxStruct = []; - hListboxStruct.ValueFolder = get(hListboxS.folders,'Value'); - hListboxStruct.Value = hListbox.Value; - hListboxStruct.guiIdx = get(hListboxS.guiEnabled,'Value'); - hListboxStruct.nwbLoadFiles = get(hListboxS.cellExtractFiletype,'Value'); - if hListboxStruct.nwbLoadFiles==1;hListboxStruct.nwbLoadFiles=0;else;hListboxStruct.nwbLoadFiles=1;end + subfxn_setOutputVars(); % Make sure GUI is up-to-date on first display. onKeyPressRelease([],[],'press',hFig); @@ -213,6 +212,7 @@ % idNumIdxArray = 1; ok = 0; if isvalid(hFig) + subfxn_setOutputVars() close(hFig) end commandwindow @@ -233,6 +233,7 @@ ok = 1; end if isvalid(hFig) + subfxn_setOutputVars() close(hFig) end return; @@ -495,9 +496,17 @@ function movieSettingsCallback(source,eventdata) function exitCallback(source,eventdata) breakMovieLoop = 1; exitFlag = 1; + subfxn_setOutputVars() close(hFig) % uiresume(hFig); end + function subfxn_setOutputVars() + hListboxStruct.ValueFolder = get(hListboxS.folders,'Value'); + hListboxStruct.Value = hListbox.Value; + hListboxStruct.guiIdx = get(hListboxS.guiEnabled,'Value'); + hListboxStruct.nwbLoadFiles = get(hListboxS.cellExtractFiletype,'Value'); + if hListboxStruct.nwbLoadFiles==1;hListboxStruct.nwbLoadFiles=0;else;hListboxStruct.nwbLoadFiles=1;end + end function startMethodCallback(source,eventdata) breakMovieLoop = 1; startMethodFlag = 1; @@ -508,15 +517,22 @@ function runMoviesToggleCallback(source,eventdata) if enableMoviePreview==1 breakMovieLoop = 1; enableMoviePreview = 0; - set(runMoviesToggleHandle,'String','Do not preview movies (click to enable)'); + set(runMoviesToggleHandle,'String',subfxn_previewMovieState()); elseif enableMoviePreview==0 enableMoviePreview = 1; breakMovieLoop = 0; - set(runMoviesToggleHandle,'String','Preview movies by selecting one folder (click to disable).'); + set(runMoviesToggleHandle,'String',subfxn_previewMovieState()); movieCallback(); end % breakLoop = ~breakLoop; - end + end + function returnStr = subfxn_previewMovieState() + if enableMoviePreview==0 + returnStr = 'Do not preview movies (click to enable previews)'; + elseif enableMoviePreview==1 + returnStr = 'Preview movies by selecting one folder in "Loaded folders" (click to disable).'; + end + end function callback_addFolders(source,eventdata) % Set current method to modelAddNewFolders and start method. hListbox.Value = 2; @@ -699,7 +715,7 @@ function frameCallback(source,eventdata) bOff = 1; fontSizeH = 11; - runMoviesToggleHandle = uicontrol('style','pushbutton','Units', 'normalized','position',[bOff 45 98 2]/100,'FontSize',fontSizeH,'string','Preview movies by selecting one folder in "Loaded folders" (click this button to disable).','BackgroundColor',buttonBackgroundColor,'callback',@runMoviesToggleCallback); + runMoviesToggleHandle = uicontrol('style','pushbutton','Units', 'normalized','position',[bOff 45 98 2]/100,'FontSize',fontSizeH,'string',subfxn_previewMovieState(),'BackgroundColor',buttonBackgroundColor,'callback',@runMoviesToggleCallback); fileFilterRegexpHandle = uicontrol('style','edit','Units', 'normalized','position',[bOff dy txtW 2]/100,'FontSize',fontSizeH,'string',obj.fileFilterRegexp,'callback',@movieSettingsCallback,'KeyReleaseFcn',@movieSettingsCallback); uicontrol('Style','text','String','Processed movie regular expression:','Units','normalized','Position',[bOff dy+dz txtW dz]/100,'BackgroundColor',figBackgroundColor,'ForegroundColor',figTextColor,'HorizontalAlignment','Left','FontWeight','normal','FontSize',fontSizeH); @@ -733,6 +749,7 @@ function movieCallback(source,eventdata) movieCheck = cell([1 nFiles]); inputMovieDims = cell([1 nFiles]); inputMoviePath = cell([1 nFiles]); + inputMovieMinMax = cell([1 nFiles]); for zz = 1:nFiles fileList{zz} = getFileList(thisFolderPath,expCheck{zz}); if isempty(fileList{zz}) @@ -757,6 +774,9 @@ function movieCallback(source,eventdata) [~,fileName{zz},fileExt] = fileparts(inputMoviePath{zz}); fileName{zz} = [fileName{zz} fileExt]; fileName{zz} = strrep(fileName{zz},'_','\_'); + + inputMovieMinMax{zz}(1) = prctile(thisFrame{zz}(:),0.1); + inputMovieMinMax{zz}(2) = prctile(thisFrame{zz}(:),99.9); end try delete(movieAxes) @@ -804,6 +824,7 @@ function movieCallback(source,eventdata) [thisFrame,~,~] = ciapkg.io.readFrame(inputMoviePath{1},i,'inputDatasetName',obj.inputDatasetName); set(movieImgHandle,'CData',thisFrame); set(movieAxes,'xcolor',figTextColor);set(movieAxes,'ycolor',figTextColor); + caxis(movieAxes,[inputMovieMinMax{1}(1) inputMovieMinMax{1}(2)]) end if movieCheck{2}==1 @@ -811,6 +832,12 @@ function movieCallback(source,eventdata) [thisFrame2,~,~] = ciapkg.io.readFrame(inputMoviePath{2},i,'inputDatasetName',obj.inputDatasetName); set(movieImgHandleTwo,'CData',thisFrame2); set(movieAxesTwo,'xcolor',figTextColor);set(movieAxesTwo,'ycolor',figTextColor); + caxis(movieAxesTwo,[inputMovieMinMax{2}(1) inputMovieMinMax{2}(2)]) + end + + % If so, only display a frame and then exit. + if enableMoviePreview==0||isempty(obj.inputFolders) + return; end try @@ -836,12 +863,7 @@ function movieCallback(source,eventdata) disp(repmat('@',1,7)) disp(getReport(err,'extended','hyperlinks','on')); disp(repmat('@',1,7)) - end - - % If so, only display a frame and then exit. - if enableMoviePreview==0||isempty(obj.inputFolders) - return; - end + end for zzz = 1:length(movieCheck) if movieCheck{zzz}==1 diff --git a/@ciatah/computeCellDistances.m b/@ciatah/computeCellDistances.m index a755951..64142fd 100644 --- a/@ciatah/computeCellDistances.m +++ b/@ciatah/computeCellDistances.m @@ -1,4 +1,17 @@ function obj = computeCellDistances(obj) + % Calculates within session cell-cell distances. + % Biafra Ahanonu + % started: 2014.07.31 + % 2021.07.23 [13:50:08] branched from CIAtah + % branch from calciumImagingAnalysis 2020.05.07 [15:16:56] + % inputs + % + % outputs + % + + % changelog + % 2021.07.23 [00:22:22] - Added plots that show the distribution of cell-cell distances. + obj.sumStats = []; obj.sumStats.cellDistances = []; obj.sumStats.cellPairs = []; @@ -15,6 +28,8 @@ % disp([num2str(thisFileNum) '/' num2str(nFiles) ': ' obj.fileIDNameArray{obj.fileNum}]); % try + % obj.modelVarsFromFilesCheck(thisFileNum); + methodNum = 2; if methodNum==1 disp('Using previously computed centroids...') @@ -25,7 +40,7 @@ % distanceMatrix = diag(zeros(1,npts))+squareform(distMatrix); else % catch - [inputSignals, inputImages, signalPeaks, signalPeaksArray, valid] = modelGetSignalsImages(obj); + [inputSignals, inputImages, signalPeaks, signalPeaksArray, valid] = modelGetSignalsImages(obj,'returnType','raw'); nIDs = length(obj.stimulusNameArray); nSignals = size(inputSignals,1); if isempty(inputImages);continue;end @@ -33,11 +48,12 @@ [xCoords, yCoords] = findCentroid(inputImages,'thresholdValue',0.4,'imageThreshold',0.4,'roundCentroidPosition',0); % continue; end - distMatrix = pdist([xCoords(:)*obj.MICRON_PER_PIXEL yCoords(:)*obj. MICRON_PER_PIXEL]); + distMatrix = squareform(pdist([xCoords(:)*obj.MICRON_PER_PIXEL yCoords(:)*obj. MICRON_PER_PIXEL])); distMatrix(logical(eye(size(distMatrix)))) = NaN; + % figure;imagesc(distMatrix==0);colorbar; distMatrixPairs = distMatrix(:); - distMatrixPairs(~isnan(distMatrixPairs)); + distMatrixPairs = distMatrixPairs(~isnan(distMatrixPairs)); nPtsAdd = length(distMatrixPairs); obj.sumStats.cellDistances(end+1:end+nPtsAdd,1) = distMatrixPairs; @@ -49,7 +65,42 @@ disp(repmat('@',1,7)) end end + + % plot outputs + figure; + clear g; + maxVal = ceil(nanmax(obj.sumStats.cellDistances(:))); + edgeVals = [-1:(maxVal+1)]; + g(1,1) = gramm('x',obj.sumStats.cellDistances,'color',obj.sumStats.sessionStr); + g(1,2)=copy(g(1)); + g(2,1)=copy(g(1)); + g(2,2)=copy(g(1)); + % g.facet_grid(obj.sumStats.sessionStr,[]); + % g.stat_density(); + g(1,1).stat_bin('normalization','probability','geom','line','edges',edgeVals); %Default binning (30 bins) + %Normalization to 'probability' + % g(2,1).stat_bin('normalization','probability','geom','overlaid_bar'); + % g(2,1).set_title('''normalization'',''probability''','FontSize',10); + g(2,1).stat_bin('normalization','cumcount','geom','line','edges',edgeVals); + g(2,1).set_title('Zoomed','FontSize',10); + g(2,1).axe_property('XLim',[0 20],'YLim',[0 200]); + % xlim([0 20]);ylim([0 200]); + + %Normalization to cumulative count + g(1,2).stat_bin('normalization','cumcount','geom','line','edges',edgeVals); + g(1,2).set_title('''normalization'',''cumcount''','FontSize',10); + + %Normalization to cumulative density + g(2,2).stat_bin('normalization','cdf','geom','stairs','edges',edgeVals); + g(2,2).set_title('''normalization'',''cdf''','FontSize',10); + + g.set_title('Cell-cell distances within sessions'); + + g.draw(); + + % line([5 5],[0 200],'Color','k','LineStyle','--','Parent',g.facet_axes_handles(3)); + savePath = [obj.dataSavePath obj.protocol{obj.fileNum} '_cellDistanceStats.csv']; disp(['saving data to: ' savePath]) writetable(struct2table(obj.sumStats),savePath,'FileType','text','Delimiter',','); diff --git a/@ciatah/getRegistrationSettings.m b/@ciatah/getRegistrationSettings.m index 5178ad7..4227769 100644 --- a/@ciatah/getRegistrationSettings.m +++ b/@ciatah/getRegistrationSettings.m @@ -22,6 +22,8 @@ % 2021.06.21 [20:52:36] - Multi-column layout since most computers are widescreen now. % 2021.06.29 [12:52:36] - Added regRegionUseBtwnSessions support and made fix for loading prior settings if they do not contain new settings. % 2021.07.06 [09:42:09] - Switch to callbacks to close instead of using pause, allows for more flexibility going forward and use with MATLAB Online. + % 2021.07.13 [17:55:30] - Added support for certain options (e.g. motion correction) to give a vector + % 2021.07.22 [12:10:10] - Added movie detrend options. % TODO % DONE: Allow user to input prior settings, indicate those changed from default by orange or similar color. @@ -48,6 +50,8 @@ userSelectStr = 'User selects specific value.'; userSelectVal = 0; defaultTooltips = 'NO TIPS FOR YOU'; + + vectorAllowList = {'motionCorrectionRefFrame'}; % Options that allow users to manually set the value userOptionsAllowManualSelect = {... @@ -227,6 +231,16 @@ tS.medianFilterSize.val = {{3,userSelectVal,5,7,9,11,13,15}}; tS.medianFilterSize.str = {{3,userSelectStr,5,7,9,11,13,15}}; tS.medianFilterSize.tooltip = {{['The size in pixels of the median filter.' 10 'If "medianFilter" is selected for preprocessing.']}}; + + % =================================== + tS.MOVIE_DETREND______________ = []; + tS.MOVIE_DETREND______________.val = {{'====================='}}; + tS.MOVIE_DETREND______________.str = {{'====================='}}; + tS.MOVIE_DETREND______________.tooltip = {{'====================='}}; + tS.detrendDegree = []; + tS.detrendDegree.val = {{1,userSelectVal,2,3,4,5,6}}; + tS.detrendDegree.str = {{1,userSelectStr,2,3,4,5,6}}; + tS.detrendDegree.tooltip = {{'For "detrend" function to compensate for photobleaching, the nth-degree polynomial trend to fit. Usually 1 (linear fit) if sufficient.'}}; % =================================== tS.MOVIE_DOWNSAMPLING______________ = []; @@ -531,7 +545,9 @@ function subfxnInterfaceCallback(hObject,callbackdata) end if strcmp(gString{gValue},userSelectStr)==1 inputCheck = 'Americans love a winner.'; - while isnan(str2double(inputCheck))==1|length(str2num(inputCheck))~=1 + lengthTooLongFlag = 1; + nanCheckFlag = 1; + while nanCheckFlag==1||lengthTooLongFlag==1 movieSettings = inputdlg({... gTooltip... },... @@ -543,14 +559,28 @@ function subfxnInterfaceCallback(hObject,callbackdata) if isempty(movieSettings) inputCheck = []; - uiwait(msgbox('Re-enter a value, do not CANCEL the input dialog.')); + uiwait(ciapkg.overloaded.msgbox('Re-enter a value, do not CANCEL the input dialog.')); else inputCheck = movieSettings{1}; % Check users has input correct, else ask again. - if isnan(str2double(inputCheck))==1|length(str2num(inputCheck))~=1 - uiwait(msgbox('Please input a SINGLE numeric value (no strings or vectors).')); + if length(str2num(inputCheck))~=1 + lengthTooLongFlag = 1; + end + if isnan(str2num(inputCheck)) + nanCheckFlag = 1; + end + if nanCheckFlag==1||lengthTooLongFlag==1 + if any(ismember(thisProperty,vectorAllowList)) + nanCheckFlag = 0; + lengthTooLongFlag = 0; + else + uiwait(ciapkg.overloaded.msgbox('Please input a SINGLE numeric value (no strings or vectors).')); + end + else + nanCheckFlag = 0; + lengthTooLongFlag = 0; end - end + end end gStringNew = [movieSettings{1};gString]; set(hObject,'String',gStringNew); diff --git a/@ciatah/help.m b/@ciatah/help.m index b3ef867..b04fac1 100644 --- a/@ciatah/help.m +++ b/@ciatah/help.m @@ -27,7 +27,7 @@ disp(helpText); disp(javaTmpStr); - uiwait(msgbox(helpText,'Note to user','modal')); + uiwait(ciapkg.overloaded.msgbox(helpText,'Note to user','modal')); % scnsize = get(0,'ScreenSize'); % [idNumIdxArray, ok] = listdlg('ListString',obj.stimulusNameArray,'ListSize',[scnsize(3)*0.2 scnsize(4)*0.25],'Name','stimuli to analyze?'); diff --git a/@ciatah/initializeObj.m b/@ciatah/initializeObj.m index 065664b..83a4625 100644 --- a/@ciatah/initializeObj.m +++ b/@ciatah/initializeObj.m @@ -125,7 +125,7 @@ if javaHeapSpaceSizeGb1 % thisFrame = max(thisFrame,[],3); - thisFrame = squeeze(thisFrame(:,:,1)); + % thisFrame = squeeze(thisFrame(:,:,1)); + thisFrame = squeeze(nanmean(thisFrame(:,:,1),3)); end [figHandle, figNo] = openFigure(9, ''); @@ -2380,7 +2429,7 @@ function fftLowpassInputMovie() % Miji; % MIJ.start manageMiji('startStop','start'); - uiwait(msgbox('press OK to view a snippet of analyzed movies','Success','modal')); + uiwait(ciapkg.overloaded.msgbox('press OK to view a snippet of analyzed movies','Success','modal')); % ask user for estimate of nPCs and nICs for fileNum = 1:nFiles try @@ -2416,7 +2465,7 @@ function fftLowpassInputMovie() % MIJ.createImage([num2str(fileNum) '/' num2str(length(ostruct.folderList)) ': ' ostruct.folderList{fileNum}],thisMovie, true); % [num2str(trueFileNum) '/' num2str(length(ostruct.folderList)) ': ' ostruct.folderList{trueFileNum}] titleStr = sprintf('%d/%d (%d/%d): %s',trueFileNum,length(ostruct.folderList),fileNum,nFiles,ostruct.folderList{trueFileNum}); - msgbox('Click movie to open next dialog box.','Success','normal') + ciapkg.overloaded.msgbox('Click movie to open next dialog box.','Success','normal') MIJ.createImage(titleStr,thisMovie, true); if size(thisMovie,1)<300 % for foobar=1:2; MIJ.run('In [+]'); end @@ -2424,14 +2473,14 @@ function fftLowpassInputMovie() end for foobar=1:2; MIJ.run('Enhance Contrast','saturated=0.35'); end MIJ.run('Start Animation [\]'); - uiwait(msgbox('press OK to move onto next movie','Success','modal')); + uiwait(ciapkg.overloaded.msgbox('press OK to move onto next movie','Success','modal')); % MIJ.run('Close All Without Saving'); manageMiji('startStop','closeAllWindows'); catch err disp(repmat('@',1,7)) disp(getReport(err,'extended','hyperlinks','on')); disp(repmat('@',1,7)) - msgbox('Press E in movie GUI to move onto next movie, close this box to continue','Success','modal') + ciapkg.overloaded.msgbox('Press E in movie GUI to move onto next movie, close this box to continue','Success','modal') playMovie(thisMovie); end diff --git a/@ciatah/modelVarsFromFilesCheck.m b/@ciatah/modelVarsFromFilesCheck.m index 387498b..92a8fed 100644 --- a/@ciatah/modelVarsFromFilesCheck.m +++ b/@ciatah/modelVarsFromFilesCheck.m @@ -35,7 +35,10 @@ catch obj.guiEnabled = 0; % originalFileNum = + oldTmp = obj.foldersToAnalyze; + obj.foldersToAnalyze = folderNo; obj.modelVarsFromFiles(); + obj.foldersToAnalyze = oldTmp; obj.fileNum = folderNo; obj.guiEnabled = 1; skipReload = 0; diff --git a/@ciatah/modelVerifyDataIntegrity.m b/@ciatah/modelVerifyDataIntegrity.m index 0d8e370..c7ba993 100644 --- a/@ciatah/modelVerifyDataIntegrity.m +++ b/@ciatah/modelVerifyDataIntegrity.m @@ -799,7 +799,7 @@ ylabel('variance');xlabel('minutes'); box off; axis tight; set(gca,'xlim',[0 lengthMovie]); - % suptitle(thisDirSaveStr); + % ciapkg.overloaded.suptitle(thisDirSaveStr); supHandle = suptitle([strrep(obj.folderBaseSaveStr{obj.fileNum},'_',' ') ' | ' fileFilterRegexp]); set(supHandle, 'Interpreter', 'none'); diff --git a/@ciatah/pipelineListBox.m b/@ciatah/pipelineListBox.m index dbf95fd..8c7cc6e 100644 --- a/@ciatah/pipelineListBox.m +++ b/@ciatah/pipelineListBox.m @@ -49,7 +49,7 @@ % disp(hListboxStruct) % fxnsToRun{hListboxStruct.Value} if isempty(hListboxStruct) - uiwait(msgbox('Please re-select a module then press enter. Do not close figure manually.')) + uiwait(ciapkg.overloaded.msgbox('Please re-select a module then press enter. Do not close figure manually.')) idNumIdxArray = 1; ok = 0; else diff --git a/@ciatah/runPipeline.m b/@ciatah/runPipeline.m index 4f6491a..bce98dd 100644 --- a/@ciatah/runPipeline.m +++ b/@ciatah/runPipeline.m @@ -210,7 +210,7 @@ if strcmp(obj.defaultObjDir,pwd)~=1 restoredefaultpath; cd(obj.defaultObjDir); - loadBatchFxns(); + ciapkg.loadBatchFxns(); % cnmfVersionDirLoad('current','displayOutput',0); end end @@ -237,6 +237,6 @@ function subfxnCheckDirs() % Re-run load folders if certain functions are still present in the path fxnCheckList = {'CELLMax_Wrapper.m','extractor.m','normcorre.m'}; if any(cellfun(@(x) ~isempty(which(x)),fxnCheckList))==1 - loadBatchFxns; + ciapkg.loadBatchFxns; end end \ No newline at end of file diff --git a/@ciatah/setup.m b/@ciatah/setup.m index 433f6ee..5fbb046 100644 --- a/@ciatah/setup.m +++ b/@ciatah/setup.m @@ -2,7 +2,7 @@ % Biafra Ahanonu % Started: 2021.03.25 [22:11:25] (branched from ciatah.m) - uiwait(msgbox(['CIAtah setup will:' 10 '1 - check and download dependencies as needed,' 10 '2 - then ask for a list of folders to include for analysis,' 10 '3 - and finally name for movie files to look for.' 10 10 'Press OK to continue.'],'Note to user','modal')); + uiwait(ciapkg.overloaded.msgbox(['CIAtah setup will:' 10 '1 - check and download dependencies as needed,' 10 '2 - then ask for a list of folders to include for analysis,' 10 '3 - and finally name for movie files to look for.' 10 10 'Press OK to continue.'],'Note to user','modal')); % Download and load dependent software packages into "_external_programs" folder. % Also download test data into "data" folder. diff --git a/@ciatah/update.m b/@ciatah/update.m index 149b2fb..1f3f29a 100644 --- a/@ciatah/update.m +++ b/@ciatah/update.m @@ -4,6 +4,6 @@ % Notify user if they are behind version-wise. ciapkg.io.updatePkg; - uiwait(msgbox('The CIAtah GitHub website will open. Click "Clone or download" button to download most recent version of CIAtah.')) + uiwait(ciapkg.overloaded.msgbox('The CIAtah GitHub website will open. Click "Clone or download" button to download most recent version of CIAtah.')) web(obj.githubUrl); end \ No newline at end of file diff --git a/@ciatah/viewCellExtractionOnMovie.m b/@ciatah/viewCellExtractionOnMovie.m index 4b32a89..285e4d1 100644 --- a/@ciatah/viewCellExtractionOnMovie.m +++ b/@ciatah/viewCellExtractionOnMovie.m @@ -388,7 +388,7 @@ continue; end displayStrMovie = [num2str(thisFileNumIdx) '/' num2str(nFilesToAnalyze) '[' num2str(movieNo) '/' num2str(nMovies) ']' ': ' obj.folderBaseDisplayStr{obj.fileNum}]; - msgHandle = msgbox('Change contrast by pressing "j"'); + msgHandle = ciapkg.overloaded.msgbox('Change contrast by pressing "j"'); [exitSignal, movieStruct] = playMovie(movieListTmp2{1},'extraTitleText',displayStrMovie,'primaryPointsOverlay',inputImages,'primaryPointsOverlayThreshold',thresholdOutline); % Remove msg box @@ -560,7 +560,7 @@ displayStrMovie = [num2str(thisFileNumIdx) '/' num2str(nFilesToAnalyze) '[' num2str(movieNo) '/' num2str(nMovies) ']' ': ' obj.folderBaseDisplayStr{obj.fileNum}]; switch options.videoPlayer case 'matlab' - msgHandle = msgbox('Change contrast by pressing "j"'); + msgHandle = ciapkg.overloaded.msgbox('Change contrast by pressing "j"'); [exitSignal movieStruct] = playMovie(primaryMovie,'extraTitleText',displayStrMovie); % Remove msg box @@ -571,7 +571,7 @@ % 'yes','motion','other','yes'); movieDecision = 'yes'; case 'imagej' - msgHandle = msgbox('Change contrast by pressing ctrl+shift+c'); + msgHandle = ciapkg.overloaded.msgbox('Change contrast by pressing ctrl+shift+c'); try % Miji; % MIJ.createImage([num2str(thisFileNumIdx) '/' num2str(nFilesToAnalyze) '[' num2str(movieNo) '/' num2str(nMovies) ']' ': ' obj.folderBaseSaveStr{obj.fileNum}], primaryMovie, true); @@ -582,7 +582,7 @@ for foobar=1:2; MIJ.run('Enhance Contrast','saturated=0.35'); end MIJ.run('Start Animation [\]'); clear primaryMovie; - uiwait(msgbox('press OK to move onto next movie','Success','modal')); + uiwait(ciapkg.overloaded.msgbox('press OK to move onto next movie','Success','modal')); % movieDecision = questdlg('Is the movie good?', ... % 'Movie decision', ... % 'yes','motion','other','yes'); diff --git a/@ciatah/viewCreateObjmaps.m b/@ciatah/viewCreateObjmaps.m index 8ced981..9d3e7b5 100644 --- a/@ciatah/viewCreateObjmaps.m +++ b/@ciatah/viewCreateObjmaps.m @@ -570,14 +570,14 @@ linkImgAxes(end+1) = subplotTmp(2,3,3) imagesc(emImages2); axis equal tight; box off; title('colored cell map') - suptitle(sprintf('%s | # cells = %d',obj.folderBaseDisplayStr{obj.fileNum},sum(validRegion))) + ciapkg.overloaded.suptitle(sprintf('%s | # cells = %d',obj.folderBaseDisplayStr{obj.fileNum},sum(validRegion))) drawnow linkaxes(linkImgAxes); [figHandle figNo] = openFigure(options.mapTraceGraphNo, ''); set(figHandle,'PaperUnits','inches','PaperPosition',[0 0 15 10]) - suptitle(sprintf('%s | # cells = %d',obj.folderBaseDisplayStr{obj.fileNum},sum(validRegion))) + ciapkg.overloaded.suptitle(sprintf('%s | # cells = %d',obj.folderBaseDisplayStr{obj.fileNum},sum(validRegion))) binOld = obj.binDownsampleAmount; obj.binDownsampleAmount = []; % obj.modelSaveImgToFile([],['objMapLabeled' filesep obj.subjectStr{obj.fileNum}],'current',[]); obj.modelSaveImgToFile([],'objMapLabeled','current',[]); @@ -632,7 +632,7 @@ % subplotTmp(2,3,3) % imagesc(emImages2); axis equal tight; box off; % title('colored cell map') - % suptitle(sprintf('%s | # cells = %d',obj.folderBaseDisplayStr{obj.fileNum},sum(validRegion))) + % ciapkg.overloaded.suptitle(sprintf('%s | # cells = %d',obj.folderBaseDisplayStr{obj.fileNum},sum(validRegion))) % drawnow % if options.onlyShowMapTraceGraph==1 diff --git a/@ciatah/viewMatchObjBtwnSessions.m b/@ciatah/viewMatchObjBtwnSessions.m index b7d0ef2..a7e7b7d 100644 --- a/@ciatah/viewMatchObjBtwnSessions.m +++ b/@ciatah/viewMatchObjBtwnSessions.m @@ -339,7 +339,7 @@ plot(globalCoordHere(:,1),globalCoordHere(:,2),'k.'); end linkaxes(linkAx); zoom on; - suptitle(num2str(globalNo)) + ciapkg.overloaded.suptitle(num2str(globalNo)) % montage() % globalNo % globalNo diff --git a/@ciatah/viewMovie.m b/@ciatah/viewMovie.m index fe13e07..6a26161 100644 --- a/@ciatah/viewMovie.m +++ b/@ciatah/viewMovie.m @@ -699,7 +699,7 @@ % MIJ.createImage([num2str(thisFileNumIdx) '/' num2str(nFilesToAnalyze) '[' num2str(movieNo) '/' num2str(nMovies) ']' ': ' obj.folderBaseSaveStr{obj.fileNum}], primaryMovie, true); s.Interpreter = 'tex'; s.WindowStyle = 'replace'; - msgbox('Click movie to open next dialog box.','Success','normal',s) + ciapkg.overloaded.msgbox('Click movie to open next dialog box.','Success','normal',s) MIJ.createImage(displayStrMovie, primaryMovie, true); % if size(primaryMovie,1)<300 % for foobar=1:3; MIJ.run('In [+]'); end @@ -707,7 +707,7 @@ for foobar=1:2; MIJ.run('Enhance Contrast','saturated=0.35'); end MIJ.run('Start Animation [\]'); clear primaryMovie; - % uiwait(msgbox('press OK to move onto next movie','Success','modal')); + % uiwait(ciapkg.overloaded.msgbox('press OK to move onto next movie','Success','modal')); movieDecision = questdlg('Is the movie good?', ... 'Movie decision', ... 'yes','motion','other','yes'); diff --git a/@ciatah/viewMovieRegistrationTest.m b/@ciatah/viewMovieRegistrationTest.m index 2efcbab..de3faf2 100644 --- a/@ciatah/viewMovieRegistrationTest.m +++ b/@ciatah/viewMovieRegistrationTest.m @@ -242,14 +242,14 @@ case 'imagej' try MIJ.createImage([num2str(thisFileNumIdx) '/' num2str(nFilesToAnalyze) ', ' num2str(testNo) '/' num2str(nTestToRun) ': ' obj.folderBaseSaveStr{obj.fileNum}],inputMovieRegAll{thisFileNumIdx}{testNo}, true); - msgbox('Goto Image->Adjust->Brightness/Contrast and then select different boxes to adjust contrast for easier viewing. Click on movie to open next dialog.','Note to user','modal') + ciapkg.overloaded.msgbox('Goto Image->Adjust->Brightness/Contrast and then select different boxes to adjust contrast for easier viewing. Click on movie to open next dialog.','Note to user','modal') % MIJ.run('In [+]'); % MIJ.run('In [+]'); MIJ.run('Start Animation [\]'); if testNo==1 - uiwait(msgbox('Press OK to move onto dfof version of the movie','Success','modal')); + uiwait(ciapkg.overloaded.msgbox('Press OK to move onto dfof version of the movie','Success','modal')); else - uiwait(msgbox('Press OK to move onto next movie','Success','modal')); + uiwait(ciapkg.overloaded.msgbox('Press OK to move onto next movie','Success','modal')); end % MIJ.run('Close All Without Saving'); manageMiji('startStop','closeAllWindows'); @@ -275,7 +275,7 @@ manageMiji('startStop','exit'); end - uiwait(msgbox('Users can load settings saved to "settings.mat", in each "preprocRun" sub-folder inside "preprocRunTest" folder within each folder that was just tested, in "modelPreprocessMovie" to re-use those same settings for actual movie processing.')) + uiwait(ciapkg.overloaded.msgbox('Users can load settings saved to "settings.mat", in each "preprocRun" sub-folder inside "preprocRunTest" folder within each folder that was just tested, in "modelPreprocessMovie" to re-use those same settings for actual movie processing.')) catch err display(repmat('@',1,7)) disp(getReport(err,'extended','hyperlinks','on')); diff --git a/@ciatah/viewObjmaps.m b/@ciatah/viewObjmaps.m index f5c3612..598c425 100644 --- a/@ciatah/viewObjmaps.m +++ b/@ciatah/viewObjmaps.m @@ -276,7 +276,7 @@ % suptitle([num2str(thisFileNumIdx) '/' num2str(nFilesToAnalyze) ': ' obj.folderBaseDisplayStr{obj.fileNum} ' | ' strrep(foldername,'_','\_') ' | ' validType]) titleStr = sprintf('%d/%d: %s | %s | %s\n %s | %d cells, %d total | Zoom enabled',thisFileNumIdx,nFilesToAnalyze,obj.folderBaseDisplayStr{obj.fileNum},strrep(foldername,'_','\_'),validType,obj.signalExtractionMethod,sum(valid==1),length(valid)); - suptitle(titleStr) + ciapkg.overloaded.suptitle(titleStr) % s2Pos = get(gca,'position'); s2Pos = plotboxpos(gca); @@ -339,7 +339,7 @@ suptitle([num2str(thisFileNumIdx) '/' num2str(nFilesToAnalyze) ': ' obj.folderBaseDisplayStr{obj.fileNum} ' | ' strrep(foldername,'_','\_') ' | ' validType 10 'Zoom enabled.']) titleStr = sprintf('%d/%d: %s | %s | %s\n %s | %d cells, %d total | Zoom enabled',thisFileNumIdx,nFilesToAnalyze,obj.folderBaseDisplayStr{obj.fileNum},strrep(foldername,'_','\_'),validType,obj.signalExtractionMethod,sum(valid==1),length(valid)); - suptitle(titleStr) + ciapkg.overloaded.suptitle(titleStr) end % ======= @@ -354,7 +354,7 @@ cbh = colorbar; ylabel(cbh,'# cells at that pixel location','FontSize',10); titleStr = sprintf('Cell overlap | %d/%d: %s | %s | %s\n %s | %d cells, %d total | Zoom enabled',thisFileNumIdx,nFilesToAnalyze,obj.folderBaseDisplayStr{obj.fileNum},strrep(foldername,'_','\_'),validType,obj.signalExtractionMethod,sum(valid==1),length(valid)); - suptitle(titleStr) + ciapkg.overloaded.suptitle(titleStr) catch err disp(repmat('@',1,7)) diff --git a/@ciatah/viewSubjectMovieFrames.m b/@ciatah/viewSubjectMovieFrames.m index db872b5..d1734c8 100644 --- a/@ciatah/viewSubjectMovieFrames.m +++ b/@ciatah/viewSubjectMovieFrames.m @@ -79,7 +79,7 @@ MIJ.createImage(thisSubjectStr{1}, subjectMovieFrames, true); % pause end - uiwait(msgbox('press OK to finish','Success','modal')); + uiwait(ciapkg.overloaded.msgbox('press OK to finish','Success','modal')); % MIJ.run('Close All Without Saving'); manageMiji('startStop','closeAllWindows'); case 2 @@ -125,7 +125,7 @@ end % pause end - uiwait(msgbox('press OK to finish','Success','modal')); + uiwait(ciapkg.overloaded.msgbox('press OK to finish','Success','modal')); % MIJ.run('Close All Without Saving'); manageMiji('startStop','closeAllWindows'); case 3 @@ -157,7 +157,7 @@ disp(identifyingText) MIJ.createImage('Montage', primaryMovie, true); % for foobar=1:3; MIJ.run('In [+]'); end - uiwait(msgbox('press OK to finish','Success','modal')); + uiwait(ciapkg.overloaded.msgbox('press OK to finish','Success','modal')); % MIJ.run('Close All Without Saving'); manageMiji('startStop','closeAllWindows'); case 4 @@ -248,7 +248,7 @@ display(repmat('@',1,7)) end end - uiwait(msgbox('press OK to finish','Success','modal')); + uiwait(ciapkg.overloaded.msgbox('press OK to finish','Success','modal')); % MIJ.run('Close All Without Saving'); manageMiji('startStop','closeAllWindows'); otherwise diff --git a/ciapkg/classification/signalSorter.m b/ciapkg/classification/signalSorter.m index 74ea6af..a6983a6 100644 --- a/ciapkg/classification/signalSorter.m +++ b/ciapkg/classification/signalSorter.m @@ -72,6 +72,8 @@ % 2020.10.13 [22:31:23] - Users can now scroll through cells using mouse scroll wheel. % 2021.03.10 [16:33:23] - User can now input just NWB path without a blank variable for inputSignals. Also added support for CIAtah mat files. % 2021.05.09 [15:20:18] - Since ciapkg.io.loadSignalExtraction already supports loading NWB or CIAtah MAT-file cell extraction files, remove remove redundancy and only call ciapkg.io.loadSignalExtraction rather than loadNeurodataWithoutBorders. Added support for progress bar when movie not input. + % 2021.07.12 [10:14:21] - Changed call to overloaded functions to `ciapkg.overloaded` to avoid altering users Matlab workspace native functions. + % 2021.07.12 [11:15:06] - Change selection of cell on the maps to be instantaneous for where the mouse location is, much faster, don't have to wait for ginputCustom cross-hairs to show. Users can still show crosshairs with 'V'. % TODO % DONE: New GUI interface to allow users to scroll through video and see cell activity at that point % DONE: allow option to mark rest as bad signals @@ -708,6 +710,13 @@ function plotSignalStatistics(inputSignals,inputImageSizes,inputStr,pointColor, mkdir(tmpDir); end + % ========================================== + % Set constants + % Binary: 1 = show ciapkg.overloaded.ginputCustom + showCrossHairs = 0; + % ========================================== + + subplotCustom = @(x,y,z) subaxis(x,y,z, 'Spacing', 0.07, 'Padding', 0, 'MarginTop', 0.1,'MarginBottom', 0.07,'MarginLeft', 0.03,'MarginRight', 0.07); % ,'Holdaxis',1 mainFig = figure(1); @@ -1704,7 +1713,9 @@ function subfxnUserInputGui(replyTmp) i = lastSortedSignal; % 'V' Allow user to select and go to cell on cellmap elseif isequal(reply, 118) + showCrossHairs = 1; subfxnSelectCellOnCellmap(); + showCrossHairs = 0; % 'B' toggle movie frame montage and frame select elseif isequal(reply, 98) if options.peakTrigMovieMontage==1 @@ -1916,7 +1927,7 @@ function subfxnUserInputGui(replyTmp) caxis(thisHandle,[minCurr maxCurr]); warning on - uiwait(msgbox('Adjust the contrast then hit OK','Contrast')); + uiwait(ciapkg.overloaded.msgbox('Adjust the contrast then hit OK','Contrast')); % Grab from the UI llabels for Window Minimum and Maximum options.movieMax = str2num(htool.Children(1).Children(3).Children.Children(2).Children.Children(2).Children(2).String)/fixMultiplier; options.movieMin = str2num(htool.Children(1).Children(3).Children.Children(2).Children.Children(2).Children(5).String)/fixMultiplier; @@ -2081,7 +2092,13 @@ function mouseWheelChange(hObject, callbackdata, handles) set(gcf,'uicontextmenu',conMenu); end function subfxnSelectCellOnCellmap(source,eventdata) - [xUser,yUser,~] = ginputCustom(1); + if showCrossHairs==1 + [xUser,yUser,~] = ciapkg.overloaded.ginputCustom(1); + else + mouseLoc = get(gca, 'CurrentPoint'); + xUser = mouseLoc(1,1); + yUser = mouseLoc(1,2); + end mapTags = {'objMapPlotLocHandle','objMapZoomPlotLocHandle'}; thisPlotTag = find(ismember(mapTags, get(gca,'tag'))); if isempty(thisPlotTag) @@ -2130,6 +2147,7 @@ function subfxnSelectCellOnCellmap(source,eventdata) end % Force exit current display loop and display chosen cell since callback. keyIn = 1e7; + showCrossHairs = 0; end function sliderZoomCallback(source,eventdata) % When user zooms in on the activity trace, adjust the slider range accordingly @@ -2322,7 +2340,7 @@ function subfxnLostFocusMainFig(jAxis, jEventData, hFig) 'EquivDiameter>3,<30',sepStrNum,... 'signalSnr>1.45',sepStrNum,... 'slopeRatio>0.02',sepStrNum,sepStrNum]; - % msgbox(instructionStr) + % ciapkg.overloaded.msgbox(instructionStr) tmpHandle = figure(2); close(tmpHandle); diff --git a/ciapkg/download/downloadMiji.m b/ciapkg/download/downloadMiji.m index 630944e..c8d686d 100644 --- a/ciapkg/download/downloadMiji.m +++ b/ciapkg/download/downloadMiji.m @@ -95,7 +95,7 @@ unzipPath = [signalExtractionDir filesep outputDir{gitNo}]; if ismac - uiwait(msgbox(['Congrats! You are special and on a Mac. Please go to "' signalExtractionDir '" folder, install Fiji there (drag icon into folder), *then* click OK!'])); + uiwait(ciapkg.overloaded.msgbox(['Congrats! You are special and on a Mac. Please go to "' signalExtractionDir '" folder, install Fiji there (drag icon into folder), *then* click OK!'])); modelAddOutsideDependencies('miji'); elseif exist(unzipPath,'dir')~=7 % Unzip the repo file diff --git a/ciapkg/image/thresholdImages.m b/ciapkg/image/thresholdImages.m index cb9a185..1667c89 100644 --- a/ciapkg/image/thresholdImages.m +++ b/ciapkg/image/thresholdImages.m @@ -22,6 +22,7 @@ % 2019.07.17 [00:29:16] - Added support for sparse input images (mainly ndSparse format). % rather than converting to a cell % 2021.07.06 [10:12:33] - Added support for fast thresholding using vectorized form, faster than parfor loop. + % 2021.07.06 [18:57:02] - Fast border calculation using convn for options.fastThresholding==1, less precise than bwboundaries or bwareafilt but works for fast display purposes. % TODO % @@ -151,15 +152,31 @@ end if options_getBoundaryIndex==1 - parfor(imageNo=1:nImages,nWorkers) - thisFilt = inputImages(:,:,imageNo); - maxVal = nanmax(thisFilt(:)); - cutoffVal = maxVal*options_threshold; - boundaryIndices{imageNo} = subfxn_getBoundaries(thisFilt,options_binary,options_getBoundaryIndex,options_boundaryHoles,cutoffVal) - if ~verLessThan('matlab', '9.2') - send(D, imageNo); % Update - end + % inputImagesTmp = diff(inputImages>0,[],1); + % inputImagesTmp = convn(inputImages>0,[-1 -1 -1; -1 1 -1; -1 -1 -1;]); + + % tic + % inputImagesTmp = convn(inputImages>0,[0 1 0; 1 0 1; 0 1 0;],'same'); + inputImagesTmp = convn(inputImages>0,[-1 -1 -1; -1 8 -1; -1 -1 -1;],'same'); + % figure + for imageNo = 1:nImages + % imagesc(inputImagesTmp(:,:,imageNo)+inputImages(:,:,imageNo));colorbar;pause + iFilt = inputImagesTmp(:,:,imageNo); + boundaryIndices{imageNo} = find(iFilt==2|iFilt==3|iFilt==1)'; end + % toc + + % tic + % parfor(imageNo=1:nImages,nWorkers) + % thisFilt = inputImages(:,:,imageNo); + % maxVal = nanmax(thisFilt(:)); + % cutoffVal = maxVal*options_threshold; + % boundaryIndices{imageNo} = subfxn_getBoundaries(thisFilt,options_binary,options_getBoundaryIndex,options_boundaryHoles,cutoffVal) + % if ~verLessThan('matlab', '9.2') + % send(D, imageNo); % Update + % end + % end + % toc end return; end diff --git a/ciapkg/io/loadMovieList.m b/ciapkg/io/loadMovieList.m index 6c338c9..5a8e811 100644 --- a/ciapkg/io/loadMovieList.m +++ b/ciapkg/io/loadMovieList.m @@ -148,8 +148,10 @@ % Remove any frames that are zero or negative, not valid. if ~isempty(options.frameList) - subfxnDisplay(['Removing invalid frames from user input frame list (negative or zero).'],options); - options.frameList(options.frameList<1) = []; + if any(options.frameList<1) + subfxnDisplay(['Removing invalid frames from user input frame list (negative or zero).'],options); + options.frameList(options.frameList<1) = []; + end end % ======================== diff --git a/ciapkg/io/manageMiji.m b/ciapkg/io/manageMiji.m index 726d5d6..46231dd 100644 --- a/ciapkg/io/manageMiji.m +++ b/ciapkg/io/manageMiji.m @@ -9,6 +9,7 @@ function manageMiji(varargin) % changelog % 2021.06.20 [00:20:38] - Add support for setting up ImageJ along with closing all windows to future proof any changes to those calls. + % 2021.07.16 [13:34:57] - Check that ImageJ already in java path to prevent duplicate loading and wasting time. % TODO % @@ -94,12 +95,28 @@ function manageMiji(varargin) imagejPath = [ciapkg.getDirExternalPrograms filesep 'imagej']; pathsToAdd = {[imagejPath filesep 'mij.jar'],[imagejPath filesep 'ij.jar']}; nPaths = length(pathsToAdd); - for i = 1:nPaths - thisPath = pathsToAdd{i}; - disp('Loading MIJI + ImageJ.') - fprintf('Adding to Java path: %s\n',thisPath); - javaaddpath(thisPath); - end + + javaDyna = javaclasspath('-dynamic'); + % matchIdx = cellfun(@isempty,regexpi(javaDyna,pathsToAdd)); + matchIdx = ismember(pathsToAdd,javaDyna); + % cellfun(@(x) javarmpath(x),javaDyna(matchIdx)); + % javaDynaPathStr = join(javaDyna(matchIdx),''','''); + if any(~matchIdx) + for i = 1:nPaths + if matchIdx(i)==1 + continue; + end + thisPath = pathsToAdd{i}; + disp('Loading MIJI + ImageJ.') + fprintf('Adding to Java path: %s\n',thisPath); + javaaddpath(thisPath); + end + % eval(sprintf('javarmpath(''%s'');',javaDynaPathStr{1})) + else + disp('ImageJ already loaded!') + end + + case 'closeAllWindows' % Closes all open windows but leaves ImageJ running. diff --git a/ciapkg/motion_correction/computeManualMotionCorrection.m b/ciapkg/motion_correction/computeManualMotionCorrection.m index 76794b3..32b46d7 100644 --- a/ciapkg/motion_correction/computeManualMotionCorrection.m +++ b/ciapkg/motion_correction/computeManualMotionCorrection.m @@ -21,6 +21,8 @@ % TODO % Add ability to auto-crop if inputs are not of the right size them convert back to correct size after manual correction % inputRegisterImage - [x y nCells] - Image to register to. + % Add second window that shows the differences between the two images + % Add a plot that shows the sum(diff(imgA-imgB)) to give users a metric. %======================== % Int: frame to use in inputImages for register in default mode diff --git a/ciapkg/neighbor/viewNeighborsAuto.m b/ciapkg/neighbor/viewNeighborsAuto.m index ed2e07e..f38f075 100644 --- a/ciapkg/neighbor/viewNeighborsAuto.m +++ b/ciapkg/neighbor/viewNeighborsAuto.m @@ -173,7 +173,7 @@ function viewNeighborsAuto(inputImages, inputSignals, neighborsCell, varargin) ylabel('Cell activity') title('Activity traces for selected and neighboring cells (Zoom enabled)') legend(strsplit(num2str(nList),' '),'Location','southoutside','Orientation','horizontal') - % suptitle(instructionStr); + % ciapkg.overloaded.suptitle(instructionStr); zoom on % plot temporal correlations diff --git a/ciapkg/signal_processing/computeSignalPeaks.m b/ciapkg/signal_processing/computeSignalPeaks.m index bc472b6..23772f5 100644 --- a/ciapkg/signal_processing/computeSignalPeaks.m +++ b/ciapkg/signal_processing/computeSignalPeaks.m @@ -362,7 +362,7 @@ function nUpdateParforProgress(~) hold(holdVal); title(sprintf('%d peaks | Zoom is enabled for closer look at peaks',length(testpeaks))) zoom on - suptitle(sprintf('Right arrow key to move to next signal | press ''e'' to exit | threshold = %0.2f | signal %d/%d',numStdsForThresh,signalNum,nSignals)) + ciapkg.overloaded.suptitle(sprintf('Right arrow key to move to next signal | press ''e'' to exit | threshold = %0.2f | signal %d/%d',numStdsForThresh,signalNum,nSignals)) end end function [Nhat] = computePeakForSignalOopsi(inputSignal,testpeaks, options, varargin) diff --git a/ciapkg/tracking/removeIncorrectObjs.m b/ciapkg/tracking/removeIncorrectObjs.m index ea6f847..5ec09e9 100644 --- a/ciapkg/tracking/removeIncorrectObjs.m +++ b/ciapkg/tracking/removeIncorrectObjs.m @@ -292,8 +292,8 @@ % figure(pathNo+100) % plot(trackingTableFiltered.XM_cm,trackingTableFiltered.YM_cm) fileInfoSaveStr = [strrep(strrep(fileInfo.date,'\','/'),'_','.') ' ' fileInfo.protocol ' ' fileInfo.subject ' ' fileInfo.assay]; - suptitle(fileInfoSaveStr); - % suptitle(strrep(strrep(tablePath,'\','/'),'_','.')) + ciapkg.overloaded.suptitle(fileInfoSaveStr); + % ciapkg.overloaded.suptitle(strrep(strrep(tablePath,'\','/'),'_','.')) % =============== % save file diff --git a/ciapkg/view/playMovie.m b/ciapkg/view/playMovie.m index df4f6a6..b1eef0c 100644 --- a/ciapkg/view/playMovie.m +++ b/ciapkg/view/playMovie.m @@ -470,8 +470,8 @@ end case 3 % Threshold inputs if images given - [inputImages, boundaryIndices, numObjects] = thresholdImages(options.primaryPointsOverlay,'fastThresholding',1,'threshold',options.primaryPointsOverlayThreshold,'getBoundaryIndex',1,'imageFilter','median','medianFilterNeighborhoodSize',3); - options.primaryPointsOverlay = [boundaryIndices{:}]; + [inputImages, boundaryIndices, numObjects] = thresholdImages(options.primaryPointsOverlay,'fastThresholding',1,'threshold',options.primaryPointsOverlayThreshold,'getBoundaryIndex',1,'imageFilter','median','medianFilterNeighborhoodSize',7); + options.primaryPointsOverlay = [boundaryIndices{:}] otherwise disp('Incorrect primaryPointsOverlay input, ignoring.') options.primaryPointsOverlay = []; @@ -1229,7 +1229,7 @@ function subfxn_respondUserInput(keyInTmp) warning on - uiwait(msgbox('Adjust the contrast then hit OK','Contrast')); + uiwait(ciapkg.overloaded.msgbox('Adjust the contrast then hit OK','Contrast')); maxMovie(usrIdxChoice) = str2num(htool.Children(1).Children(3).Children.Children(2).Children.Children(2).Children(2).String)/fixMultiplier; minMovie(usrIdxChoice) = str2num(htool.Children(1).Children(3).Children.Children(2).Children.Children(2).Children(5).String)/fixMultiplier; disp(['New max: ' num2str(maxMovie(usrIdxChoice)) ' and min: ' num2str(minMovie(usrIdxChoice))]) @@ -1524,8 +1524,8 @@ function subfxn_displayShortcuts(src,event) supTitleStr = [supTitleStr 10]; end disp(strrep(supTitleStr,titleSep, 10)) - % suptitleHandle = suptitle(strrep(strrep('/','\',supTitleStr),'_','\_')); - suptitleHandle = suptitle(supTitleStr,'titleypos',0.93); + % suptitleHandle = ciapkg.overloaded.suptitle(strrep(strrep('/','\',supTitleStr),'_','\_')); + suptitleHandle = ciapkg.overloaded.suptitle(supTitleStr,'titleypos',0.93); set(suptitleHandle,'FontName',get(0,'DefaultAxesFontName')); set(suptitleHandle,'FontSize',12,'FontWeight','normal') hold off; @@ -1567,7 +1567,7 @@ function subfxn_imageJ(inputMovie) MIJ.createImage('result', inputMovie, true); - uiwait(msgbox('press OK to move onto next movie','Success','modal')); + uiwait(ciapkg.overloaded.msgbox('press OK to move onto next movie','Success','modal')); MIJ.run('Close'); manageMiji('startStop','exit'); diff --git a/docs/docs/help_analysis_methods.md b/docs/docs/help_analysis_methods.md index 6cf5c3a..6342139 100644 --- a/docs/docs/help_analysis_methods.md +++ b/docs/docs/help_analysis_methods.md @@ -84,5 +84,10 @@ Find an overview of calcium imaging analysis methods at https://bahanonu.com/bra - https://zenodo.org/record/1119026#.XT9GdxSYVds - http://www.itsnetcal.com/ +- Minian: An open-source miniscope analysis pipeline + - https://www.biorxiv.org/content/10.1101/2021.05.03.442492v1.abstract + - https://github.com/DeniseCaiLab/minian + + ## Standards - https://github.com/NeurodataWithoutBorders/api-matlab \ No newline at end of file diff --git a/docs/docs/help_cross_session_alignment.md b/docs/docs/help_cross_session_alignment.md index 8cfe530..951a064 100644 --- a/docs/docs/help_cross_session_alignment.md +++ b/docs/docs/help_cross_session_alignment.md @@ -1,14 +1,51 @@ # Cross-day or -session cell alignment alignment -Find the main function at https://github.com/bahanonu/calciumImagingAnalysis/blob/master/classification/matchObjBtwnTrials.m +The main function used to run cross-session analysis that allows users to align cells across sessions/days can be found at: +- https://github.com/bahanonu/ciatah/blob/master/classification/matchObjBtwnTrials.m ## Algorithm overview -For details, see __Cross-day analysis of BLA neuronal activity__ methods section in the associated _Science_ paper: http://science.sciencemag.org/content/sci/suppl/2019/01/16/363.6424.276.DC1/aap8586_Corder_SM.pdf#page=10. +For details, see __Cross-day analysis of BLA neuronal activity__ methods section in the Corder*, Ahanonu*, et al. _Science_, 2019: -![image](https://user-images.githubusercontent.com/5241605/51709763-21b09e80-1fdc-11e9-9332-1d52c9ed6bd5.png) +- http://science.sciencemag.org/content/sci/suppl/2019/01/16/363.6424.276.DC1/aap8586_Corder_SM.pdf#page=10. -- Example output on several mPFC animals across multiple sessions. Color is used to indicate a global ID cell (e.g. the same cell matched across multiple days). + +![image](https://user-images.githubusercontent.com/5241605/126744851-cd6e64ab-9b83-40bf-aa38-2301276f0ccf.png) + +Below is a general description of the algorithm/method used to match cells across sessions and references the above figure. A reference to the associated book chapter will be added in the future. + +1. Load the cell extraction spatial filters and threshold them by setting to zero any values below 40% the maximum value for each spatial filter and use these thresholded filters to calculate each neuron's centroid location. You can calculate the centroid using the *regionprops* function in MATLAB. **Do not** round each neuron's centroid coordinates to the nearest pixel value as this would reduce accuracy of cross-day alignment. + +2. Next, create simplified spatial filters that contained a 10-pixel-radius circle (this can be varied based on microns-per-pixel of the movie and size of cells) centered on each neuron's centroid location. This allows you to register different days while ignoring any slight day-to-day differences in the cell extraction algorithm's estimate of each neuron's shape even if the centroid locations are similar. + +3. For each animal, we recommend that if you have *N* sessions to align that you choose the *N/2* session (rounded down to the nearest whole number) to align to (referred to as the *align session*) to compensate for any drift or other imaging changes that may have occurred during the course of the imaging protocol. + +4. For all imaging sessions create two neuron maps based on the thresholded spatial (see fig panel A, step 1, "thresholded neuron maps") and 10-pixel-radius circle (see fig panel A, step 2, "circle neuron maps") filters by taking a maximum projection across all *x* and *y* pixels and spatial filters (e.g. a max operation in the 3^rd^ dimension on a *x* × *y* × *n* neuron spatial filter matrix, where *n* = neuron number). + +5. You then need to register these neuron maps to the *align session* using *Turboreg* with rotation enabled for all animals and isometric (projective) scaling enabled for a subset of animals in cases where that improves results. The registration steps are as follows (see fig panel A, step 3): + - Register the thresholded neuron map for a given session to the *align session* threshold neuron map. + - Use the output 2D spatial transformation coordinates to also register the circle neuron maps. + - Then register the circle neuron map with that animal's *align session* circle neuron map. + - Apply the resulting 2D spatial transformation coordinates to the thresholded neuron map. + - Repeat this procedure at least five times. + - Lastly, use the final registration coordinates to transform all spatial filters from that session so they matched the *align session*'s spatial filters and repeat this process for all sessions for each animal individually. + +6. After registering all sessions to the *align session*, re-calculate all the centroid locations (see fig panel A, step 4). + +7. Set the *align session* centroids as the initial seed for all *global cells* (see fig panel A, step 5)*.* Global cells are a tag to identify neurons that you match across imaging sessions. + - For example, global cell #1 might be associated with neurons that are at index number 1, 22, 300, 42, and 240 within the cell extraction analysis matrices across each of the first five imaging sessions, respectively. + +8. Starting with the *align session* for an animal, calculate the pairwise Euclidean distance between all global cells' and the selected session's (likely 1^st^) neurons' centroids. + +9. Then identify any cases in which a global cell is within 5 μm (nominally ~2 pixels in our data, this can be varied by the user) of a selected session's neurons. This distance depends on the density of cells in your imaging sessions, a stricter cut-off should be set for more dense brain areas. When you find a match, then check that the spatial filter is correlated (e.g. with 2-D correlation coefficient, Jaccard distance, or other measure) above a set threshold (e.g. *r* > 0.4) with all other neurons associated with that global cell (see fig panel A, step 6). + +10. If a neuron passes the above criteria, add that neuron to that global cell's pool of neurons then recalculate the global cell's centroid as the mean location between all associated session neurons' centroid locations and annotate any unmatched neurons in that session as new candidate global cells. + +11. Repeat this process for all sessions associated with a given animal. + + +## Example output +- Example output of several mPFC animals across multiple sessions. Color is used to indicate a global ID cell (e.g. the same cell matched across multiple days). diff --git a/docs/docs/index.md b/docs/docs/index.md index 43a1cf5..2e88421 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -16,6 +16,8 @@ Created by __Biafra Ahanonu, PhD__. `{{ site.name }}` (pronounced cheetah, formerly `calciumImagingAnalysis` [`CIAPKG`]) is a software package for analysis of one- and two-photon calcium imaging datasets. +Currently requires `MATLAB` and runs on all major operating systems (Windows, Linux [e.g. Ubuntu], and macOS). + __Download the software at [https://github.com/bahanonu/ciatah](https://github.com/bahanonu/ciatah).__ CIAtah_logo diff --git a/docs/docs/pipeline_detailed_cross_session.md b/docs/docs/pipeline_detailed_cross_session.md index e0fc8a8..d6dc0a2 100644 --- a/docs/docs/pipeline_detailed_cross_session.md +++ b/docs/docs/pipeline_detailed_cross_session.md @@ -4,7 +4,7 @@ title: Cross-session cell alignment. # Cross-session cell alignment with `computeMatchObjBtwnTrials` -This step allows users to align cells across imaging sessions (e.g. those taken on different days). See the `Cross session cell alignment` wiki page for more details and notes on cross-session alignment. +This step allows users to align cells across imaging sessions (e.g. those taken on different days). See the [Cross session cell alignment help page](help_cross_session_alignment.md) for more details and notes on cross-session alignment. See below sections for notes on options. - Users run `computeMatchObjBtwnTrials` to do cross-day alignment (first row in pictures below). - Users then run `viewMatchObjBtwnSessions` to get a sense for how well the alignment ran. @@ -12,15 +12,61 @@ This step allows users to align cells across imaging sessions (e.g. those taken ![image](https://user-images.githubusercontent.com/5241605/49835713-eec88900-fd54-11e8-8d24-f7c426802297.png) -Users can then get the matrix that gives the session IDs + +## Output of `computeMatchObjBtwnTrials` + +The output for cross-session alignment for each animal is stored in a structure within the current `{{ code.mainclass }}` object: `obj.globalIDStruct.ANIMAL_ID` where `ANIMAL_ID` is the animal identification automatically pulled from folder names (if none is found, defaults to `m0`). Users can then get the matrix that gives the session IDs from the `{{ code.mainclass }}` class: ```Matlab -% Global IDs is a matrix of [globalID sessionID] -% Each (globalID, sessionID) pair gives the within session ID for that particular global ID +% Grab the cross session alignment structure from the current `{{ code.mainclass }}` object. +alignmentStruct = obj.globalIDStruct.ANIMAL_ID + +% Global IDs is a matrix of [globalID sessionID]. +% Each (globalID, sessionID) pair gives the within session ID for that particular global ID. globalIDs = alignmentStruct.globalIDs; ``` +Below is an example of what that `globalIDs` matrix looks like when visualized. Each column is an imaging session and each row is an individual global cell with the color indicating that global cell's within-session number. Any black cells indicate where no match was found for that global cell in that imaging day. + +Global cell output + +## Notes on `computeMatchObjBtwnTrials` options + +After starting `computeMatchObjBtwnTrials`, the below options screen will appear: +Cross session options screen + +An explanation of each option is as follows: + +- `Number of rounds to register images (integer)` + - This determines the number of rounds to register all the sessions to the "base" session used for alignment. Additional rounds of registration (e.g. we at times use up to 5 rounds) can often improve results especially in cases where there might be large lateral displacements across sessions. +- `Distance threshold to match cells cross-session (in pixels)` + - This determine the maximum distance that the algorithm should use to match cells across sessions. Ideally this value should be _below_ the within-session distance between cells to minimize false positives (e.g. matching nearby cells across sessions that are actually different cells). +- `Image binarization threshold (0 to 1, fraction each image''s max value)` + - This threshold is used to remove parts of the cell filter that are not necessarily useful for cross-session alignment, such as faint dendrites or axons along with noise produced by some algorithms in their filters (e.g. as is the case with PCA-ICA). +- `Session to align to (leave blank to auto-calculate middle session to use for alignment)` + - Leaving blank automatically selects the middle session, as this session is often a compromise between changes (e.g. drift in the field of view) that occurred between the 1st and last session. +- `Registration type (3 = rotation and iso scaling, 2 = rotation no iso scaling)` + - This is the type of _Turboreg_ registration used to align the sessions during cross-session motion correction. Avoid using iso scaling enabled (e.g. `3` or projective) unless you know in advance that you have warping in your field of view across days, else this option can lead to less optimal results compared to iso scaling disabled (e.g. `2` or affine). + - See https://www.mathworks.com/help/images/matrix-representation-of-geometric-transformations.html. +- `Run image correlation threshold? (1 = yes, 0 = no)` + - This determines whether a secondary measure will be used to match cells across sessions and decreases the probability of false positives. It does this by correlating the putative matched cell to others that have been already matched to be the same cells and adds it to the "global cell" group for that cell if it passes a pre-defined threshold as below. In general this should be enabled unless you know the imaging quality varies across sessions that would lead to a distortion in cell shapes or you are using a cell-extraction algorithm that does not produce high-quality filters. +- `Image correlation type (e.g. "corr2","jaccard")` + - This is the type of correlation measure, where `corr2` is [2-D correlation coefficient](https://www.mathworks.com/help/images/ref/corr2.html) and `jaccard` is the [Jaccard distance](https://en.wikipedia.org/wiki/Jaccard_index). The [Ochiai similarity](https://en.wikipedia.org/wiki/Cosine_similarity) is also supported. + - A list of all possible measures can be found at https://www.mathworks.com/matlabcentral/fileexchange/55190-simbin-mat1-mat2-type-mask. Note, some might not be valid and in general the above three should work for most users. +- `Image correlation threshold for matched cells (0 to 1)` + - How high the image correlation needs to be for it to be considered a match, e.g. accept the match if it has an image correlation above this amount _and_ a distance below that specified above. +- `Image correlation binarization threshold (0 to 1, fraction each image''s max value)` + - This is the threshold used for calculated image correlations. __Note__ this is different that the threshold used for cross-session cell alignment as sometimes the cross-session threshold needs to be a different value to improve alignment compared to a more relaxed threshold to improve estimation of cell shape (e.g. too high of a threshold can make all cells look similar depending on the algorithm). +- `Threshold below which registered image values set to zero` + - During registration zero values can sometimes take on very small numerical values that can cause problems for downstream analysis. This threshold sets all pixels below this value to zero to correct for this. For the most part do not change this value. +- `Visually compare image correlation values and matched images (1 = yes, 0 = no)` + - This will pop-up a GUI after running cross-session alignment to show matches that users can scroll through. +- `View full results after [viewMatchObjBtwnSessions] (1 = yes, 0 = no)` + - This will pop-up several figures showing example cells matched across sessions along with graphs that show cross-session matches with each cell colored by its global identification to help determine accuracy of results. If users go to `obj.picsSavePath` and look under the folders `matchObjColorMap`, they will find AVI and picture files with outputs related to these figures. + + + ## View cross-session cell alignment with `viewMatchObjBtwnSessions` To evaluate how well cross-session alignment works, `computeMatchObjBtwnTrials` will automatically run `viewMatchObjBtwnSessions` at the end, but users can also run it separately after alignment. The left are raw dorsal striatum cell maps from a single animal. The right shows after cross-session alignment; color is used to indicate a global ID cell (e.g. the same cell matched across multiple days). Thus, same color cell = same cell across sessions. diff --git a/docs/docs/pipeline_detailed_preprocess.md b/docs/docs/pipeline_detailed_preprocess.md index bb6b2e4..021d86b 100644 --- a/docs/docs/pipeline_detailed_preprocess.md +++ b/docs/docs/pipeline_detailed_preprocess.md @@ -7,6 +7,7 @@ title: Preprocessing calcium imaging movies After users instantiate an object of the `{{ site.name }}` class and enter a folder, they can start preprocessing of their calcium imaging data with `modelPreprocessMovie`. - See below for a series of windows to get started, the options for motion correction, cropping unneeded regions, Δ_F/F_, and temporal downsampling were selected for use in the study associated with this repository. +- There is also support for various other types of movie corrections, such as detrending a movie using linear or higher-order fits to remove the effects of photobleaching. - If users have not specified the path to Miji, a window appears asking them to select the path to Miji's `scripts` folder. - If users are using the test dataset, it is recommended that they do not use temporal downsampling. - Vertical and horizontal stripes in movies (e.g. CMOS camera artifacts) can be removed via `stripeRemoval` step. Remember to select correct `stripOrientationRemove`,`stripSize`, and `stripfreqLowExclude` options in the preprocessing options menu. diff --git a/startup.m b/startup.m index a2ac441..c3a1a4b 100644 --- a/startup.m +++ b/startup.m @@ -1,12 +1,14 @@ % Startup commands and graphics defaults % Biafra Ahanonu % started: 2013.12.07 [17:28:44] +% changelog + % 2021.07.22 [19:55:49] - loadBatchFxns to ciapkg.loadBatchFxns. -% If using startup, then restore default path before running +% If using startup, then restore default path before running startup operations. restoredefaultpath % Load all needed ciapkg directories -loadBatchFxns('skipLoadMiji'); +ciapkg.loadBatchFxns('skipLoadMiji'); % set default figure properties setFigureDefaults(); From 81485d76bc5dff2086c25e5cd6fbd518c93d10ba Mon Sep 17 00:00:00 2001 From: Biafra Ahanonu Date: Sun, 25 Jul 2021 14:39:39 -0700 Subject: [PATCH 4/5] Update startup.m --- startup.m => +ciapkg/startup.m | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename startup.m => +ciapkg/startup.m (100%) diff --git a/startup.m b/+ciapkg/startup.m similarity index 100% rename from startup.m rename to +ciapkg/startup.m From 328941d34ed337c057daef1ca1ece44f4490f9d3 Mon Sep 17 00:00:00 2001 From: Biafra Ahanonu Date: Sun, 25 Jul 2021 14:44:32 -0700 Subject: [PATCH 5/5] Update loadDependencies.m --- +ciapkg/+io/loadDependencies.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/+ciapkg/+io/loadDependencies.m b/+ciapkg/+io/loadDependencies.m index 690ddd2..3ee67f6 100644 --- a/+ciapkg/+io/loadDependencies.m +++ b/+ciapkg/+io/loadDependencies.m @@ -19,7 +19,7 @@ function loadDependencies(varargin) % 2021.06.19 [23:46:58] - Switched to support for original MIJ calling of ImageJ using just jar files, easier compatibility across MATLAB versions and OSes. % 2021.06.21 [16:45:59] - Update order. % 2021.07.13 [08:34:18] - Added backup URL for downloading mij.jar. - % 2021.07.23 [00:22:22] - Added gramm. + % 2021.07.23 [00:22:22] - Added gramm (https://github.com/piermorel/gramm) support/downloading for graphics plotting. % TODO % Verify all dependencies download and if not ask user to download again.