diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 0000000..1039c56 --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,16 @@ +## TomoBEAR authors + +Max Delbruck Center for Molecular Medicine, Berlin, Germany () + +* Mikhail Kudryashev - project leader +* Artsemi Yushkevich - developer +* Vasilii Mikirtumov - application engineer + + +Max Planck Institute of Biophysics, Frankfurt (Hesse), Germany () + +* Nikita Balyschew - core version developer + +## External modified software authors + +TomoBEAR also contains modified pieces of MATLAB source code of the Dynamo package developed by D. Castaño-Díez et al.: https://www.dynamo-em.org. diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5fb16fa --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,50 @@ +# Changelog + +All notable changes will be documented in this file. + +## v0.3.0 - 2023-05-22 + +### :rocket: New Features +* ```local_live``` data processing mode - new mode allows to make on-the-fly pre-processing and reconstructions during data collection to check the sample quality. *Currently only single-shot collected data is supported for this feature.* +* ```EER``` (*Electron Event Representation*) support: input files format perception along with ```.gain``` gain file format support are now enabled in ```MotionCor2``` module +* ```GenerateParticles``` - new module which allows to generate particles using either Dynamo (by cropping) or SUSAN (by subtomogram reconstructions) +* ```IsoNet``` - module wrapping [IsoNet](https://github.com/IsoNet-cryoET/IsoNet) - CNN for denoising and missing wedge reconstruction + +### :arrow_up: Improvements +* ```BinStacks```: added possibility to bin non-aligned stacks +* ```AreTomo```: + - enabled binned stack input + - enabled local patch-based alignment +* ```BatchRunTomo```: enabled IMOD-based patch-tracking +* ```Reconstruct```: enabled [*nonlinear anisotropic diffusion* (NAD)](https://www.sciencedirect.com/science/article/pii/S1047847701944065?via%3Dihub) filter for tomograms post-filtering +* ```GCTFCtfphaseflipCTFCorrection```: added possibility to use [CTFFIND4](https://www.sciencedirect.com/science/article/pii/S1047847715300460) + +### :bug: Major fixes +* input files perception - fixed duplicated file extension ( issue #16 ) + +--- +## v0.2.0 - 2023-02-23 + +### :rocket: New Features +* `GridEdgeEraser`: a new module which allows to identify position of the grid edge and mask it out. + * *Currently only gold grids data is supported for this feature.* + +### :arrow_up: Improvements +* `AreTomo`: + * enabled IMOD-compatible files output + * enabled tilt axis offset parameter + +### :bug: Fixes +* `EMDTemplateGeneration`: fixed EMDB URL +* `BatchRunTomo`: fixed bug which prevented running TomoBEAR project for a single tilt serie +* `GCTFCtfphaseflipCTFCorrection`: + * fixed AreTomo-aligned data usage + * fixed aligned stack usage + * fixed Ctfphaseflip usage +* `Reconstruct`: fixed reconstruction based on AreTomo-aligned data + +--- +## v0.1.2 - 2023-01-20 + +### :bug: Fixes +* `AreTomo` module: fixed parallelization and usage diff --git a/CITATION.cff b/CITATION.cff index da6c164..324167a 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -4,7 +4,22 @@ authors: - family-names: Balyschew given-names: Nikita orcid: https://orcid.org/0000-0001-7330-4628 -title: "TomoBEAR: an automated, configurable and customizable full processing pipeline for tomographic cryo electron microscopy data and subtomogram averaging" -version: 0.1.3.alpha -doi: -date-released: 2021-08-13 \ No newline at end of file + - family-names: Yushkevich + given-names: Artsemi + orcid: https://orcid.org/0000-0002-8729-9281 + - family-names: Mikirtumov + given-names: Vasilii + orcid: + - family-names: Sanchez + given-names: Ricardo M. + orcid: https://orcid.org/0000-0002-2854-0119 + - family-names: Sprink + given-names: Thiemo + orcid: https://orcid.org/0000-0002-0760-6828 + - family-names: Kudryashev + given-names: Misha + orcid: https://orcid.org/0000-0003-3550-6274 +title: "Streamlined Structure Determination by Cryo-Electron Tomography and Subtomogram Averaging using TomoBEAR" +version: 0.3.0 +doi: https://doi.org/10.1101/2023.01.10.523437 +date-released: 2023-05-22 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 29ebfa5..0000000 --- a/LICENSE +++ /dev/null @@ -1,661 +0,0 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 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 Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are 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. - - 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. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - 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 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 work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero 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 Affero 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 Affero 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 Affero 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. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero 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 Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - 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 AGPL, see -. \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..b475c3a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,13 @@ +# License + +Copyright © 2021-2023 Max Delbruck Center for Molecular Medicine (MDC) +
+Copyright © 2021 Max Planck Institute of Biophysics (MPIBP) + +This work is licensed under multiple licenses: +- The source code (MATLAB, Python, Bash, etc.) and the accompanying material are licensed under [AGPL3](LICENSES/AGPL-3.0-or-later.txt). +- The modified MATLAB source code of the Dynamo package (```dynamo/```) is licensed under [GPL2](LICENSES/GPL-2.0-or-later.txt). +- The documentation (```wiki/```), TomoBEAR logo and accompanying images (```images/```) as well as configuration files (```configurations/```) are licensed under [CC-BY-4.0](LICENSES/CC-BY-4.0.txt). +- Insignificant files are licensed under [CC0-1.0](LICENSES/CC0-1.0.txt). + +Please see the individual files for more accurate information. diff --git a/LICENSES/AGPL-3.0-or-later.txt b/LICENSES/AGPL-3.0-or-later.txt new file mode 100644 index 0000000..0c97efd --- /dev/null +++ b/LICENSES/AGPL-3.0-or-later.txt @@ -0,0 +1,235 @@ +GNU AFFERO GENERAL PUBLIC LICENSE +Version 3, 19 November 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 Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are 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. + +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. + +Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. + +A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. + +The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. + +An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. + +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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. + +Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. + +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 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 work with which it is combined will remain governed by version 3 of the GNU General Public License. + +14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of the GNU Affero 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 Affero 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 Affero 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 Affero 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. + +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 AGPL, see . diff --git a/LICENSES/CC-BY-4.0.txt b/LICENSES/CC-BY-4.0.txt new file mode 100644 index 0000000..13ca539 --- /dev/null +++ b/LICENSES/CC-BY-4.0.txt @@ -0,0 +1,156 @@ +Creative Commons Attribution 4.0 International + + Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. + +Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors. + +Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public. + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. + +Section 1 – Definitions. + + a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. + + d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. + + g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. + + i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. + + j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. + + k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. + +Section 2 – Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: + + A. reproduce and Share the Licensed Material, in whole or in part; and + + B. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. + + 3. Term. The term of this Public License is specified in Section 6(a). + + 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. + + 5. Downstream recipients. + + A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. + + B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. + + 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). + +b. Other rights. + + 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this Public License. + + 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. + +Section 3 – License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified form), You must: + + A. retain the following if it is supplied by the Licensor with the Licensed Material: + + i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of warranties; + + v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + + B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and + + C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. + + 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. + +Section 4 – Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; + + b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. +For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. + +Section 5 – Disclaimer of Warranties and Limitation of Liability. + + a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. + + b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. + + c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. + +Section 6 – Term and Termination. + + a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or + + 2. upon express reinstatement by the Licensor. + + c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. + + d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. + + e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. + +Section 7 – Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. + +Section 8 – Interpretation. + + a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. + + c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. + + d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. + +Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/LICENSES/CC0-1.0.txt b/LICENSES/CC0-1.0.txt new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/LICENSES/CC0-1.0.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/LICENSES/GPL-2.0-or-later.txt b/LICENSES/GPL-2.0-or-later.txt new file mode 100644 index 0000000..17cb286 --- /dev/null +++ b/LICENSES/GPL-2.0-or-later.txt @@ -0,0 +1,117 @@ +GNU GENERAL PUBLIC LICENSE +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) 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 this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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. + +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 convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision 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, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + +signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice diff --git a/README.md b/README.md index c21c802..fd79004 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,74 @@ -**We are mainly at the stage of testing, debugging and maitenance work. However, new features may still appear and refactorings may still take place. We will be happy, if you would try it out the current version and get back to us by using our [Issue Tracker](https://github.com/KudryashevLab/TomoBEAR/issues) or writing an e-mail to [Artsemi Yushkevich](Artsemi.Yushkevich@mdc-berlin.de?subject=[GitHub]%20TomoBEAR).** +# TomoBEAR -:tada:**The first standalone executable release for GPU workstations is available now! :tada: You may find it on the [Releases page](https://github.com/KudryashevLab/TomoBEAR/releases).** +**TomoBEAR** is a configurable and customizable modular pipeline for streamlined processing of cryo-electron tomographic data and preliminary subtomogram averaging (StA) based on best practices in the scientific research group of Dr. Misha Kudryashev[^1][^2]. -# TomoBEAR -TomoBEAR is an automated, configurable and customizable full processing pipeline for tomographic cryo-electron microscopy data and subtomogram averaging in the broad field of Cryo-ET based on best practices in the scientific research groups of [Misha Kudryashev](mailto:misha.kudryashev@gmail.com?subject=[GitHub]%20TomoBEAR): -- (previous one) [Independent Research Group (Sofja Kovaleskaja)](https://www.biophys.mpg.de/2149775/members) at the Department of Structural Biology at [MPIBP (Max Planck Institute of Biophysics)](https://www.biophys.mpg.de/en) in Frankfurt (Hesse), Germany; -- (current one) [In situ Structural Biology Group](https://www.mdc-berlin.de/kudryashev) at the [MDCMM (Max Delbrück Center of Molecular Medicine)](https://www.mdc-berlin.de) in Berlin, Germany. +![TomoBEAR Social Media Logo Image](images/TomoBEAR_gitlogo.png) + +Implementation details and benchmarks you can find in our preprint: +
Balyschew N, Yushkevich A, Mikirtumov V, Sanchez RM, Sprink T, Kudryashev M. Streamlined Structure Determination by Cryo-Electron Tomography and Subtomogram Averaging using TomoBEAR. **[Preprint]** 2023. bioRxiv doi: [10.1101/2023.01.10.523437](https://www.biorxiv.org/content/10.1101/2023.01.10.523437v1) + +> **Warning** +>
This software is currently in pre-release state. New features may still appear and refactoring may still take place between all the current and future 0.x.y versions until 1.0.0 will be ready to be released. + +## Contents + +- [Quick start](#quick-start) +- [Documentation and licensing](#documentation-and-licensing) +- [Changes and releases](#changes-and-releases) +- [Feedback and contribution](#feedback-and-contribution) +- [Citation](#citation) +- [Acknowledgements](#acknowledgements) +- [Contacts](#contacts) + +## Quick start + +### Video-tutorials + +We have prepared a range of short (8-12 min) video-tutorials explaining setup, usage and example output of the ```TomoBEAR``` to help you get started with ```TomoBEAR``` based on the [ribosome tutorial](https://github.com/KudryashevLab/TomoBEAR/wiki/Tutorials): +* [Video 1](https://drive.google.com/file/d/1Nhltdo7DbWdzPhAbnkzq7lCkDghxJrku/view?usp=share_link): how to get the latest ```TomoBEAR``` version and configure ```TomoBEAR``` and its dependencies; +* [Video 2](https://drive.google.com/file/d/12h8Vs4eUeJDJAb5S6nF2BuOX7lfvmmYo/view?usp=share_link): description of the project configuration file and the pipeline execution; +* [Video 3](https://drive.google.com/file/d/16nNdu89XUZglO_PiRKmGkK85o_nWqOB8/view?usp=share_link): additional configuration file parameters description, ```TomoBEAR```-```IMOD```-```TomoBEAR``` loop for checking tilt series alignment results and fiducials refinement (if needed); +* [Video 4](https://drive.google.com/file/d/1t3ol3KlHqBGtnZp1bnLHi_Anurd2VPcx/view?usp=share_link): checking on further intermediate results (alignment, CTF-correction, reconstruction, template matching). -## Documentation +### Pipeline structure -Information on the installation, setup and usage as well as tutorials and example results can be found in the corresponding [wiki](https://github.com/KudryashevLab/TomoBEAR/wiki). +In the following picture you can see a flow chart of the main `TomoBEAR` processing steps. As the basic input data you can use raw frame movies or already assembled tilt stacks. More on input formats you [can read here](https://github.com/KudryashevLab/TomoBEAR/wiki/Usage.md#input-data-file-formats). -## Repository structure -User branches: -- `main` - more or less stable version (*in a normal case use this one, please!*); -- `develop_live` - an experimental (non-stable) version with live data processing functionality (*warning! new functionality and bug fixes from main coming here slowly!*) +![Schematic Pipeline Image](images/pipeline_simplified.png) -All the other branches are not intended for user usage! They hold non-stable development versions (with new features, bug-fixes and refactorings). +Blue boxes outline the steps that are performed fully automatically, green boxes may require human intervention. The steps encapsulated in the red frame represent the functionality of live data processing. More detailed diagram [is located on wiki](https://github.com/KudryashevLab/TomoBEAR/wiki). -In the future we are planning to introduce wiki versioning as well, stay tuned! +> **Note** +>
Full MATLAB (source code) version of `TomoBEAR` supports workstations and single interactive nodes with GPUs on the computing clusters at the moment. We are also working towards enabling the support of binaries on the mentioned systems as well as support of both source code and binary versions of the `TomoBEAR` on HPC clusters. -## Pipeline structure +## Documentation and licensing -In the following picture you can see a flow chart which visualizes which steps `TomoBEAR` will and can do for you in an automated and parallel manner. `TomoBEAR` supports workstations and single interactive nodes with GPUs on the comuting clusters at the moment. We are also working towards enabling the support of computer clusters through a queue manager like SLURM or SGE (Sun Grid Engine). +Detailed information on the installation, setup and usage as well as tutorials and example results can be found in the corresponding [wiki](https://github.com/KudryashevLab/TomoBEAR/wiki). -Note that it is not needed to start from raw data but you can also use already assembled tilt stacks if you provide the angular information. +Please, see the [LICENSE file](LICENSE.md) for the information about how the content of this repository is licensed. -![Schematic Pipeline Image Light Mode](https://raw.githubusercontent.com/KudryashevLab/TomoBEAR/main/images/pipeline_light_mode.svg#gh-light-mode-only) -![Schematic Pipeline Image Dark Mode](https://raw.githubusercontent.com/KudryashevLab/TomoBEAR/main/images/pipeline_dark_mode.svg#gh-dark-mode-only) +## Changes and releases -Orange processing steps in the flow chart are mandatory and must be executed by TomoBEAR. Yellow boxes are optional and can be activated if desired. +The [CHANGELOG file](CHANGELOG.md) contains all notable changes corresponding to the different `TomoBEAR` releases, which are available at the [Releases page](https://github.com/KudryashevLab/TomoBEAR/releases). -## Feedback +If you want to clone a specific ```TomoBEAR``` version, please refer to the **Setup > Get source code and binary > Clone specific version** section on the wiki page [Installation and Setup](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup.md). -In case of any questions or errors do not hesitate to contact one of the provided persons mentioned in the `Contacts` section below. Alternatively, for bug reports or feature suggestions you may use our [Issue Tracker](https://github.com/KudryashevLab/TomoBEAR/issues). Please, be polite and precise! +## Feedback and contribution -# Acknowledgements +In case of any questions, issues or suggestions you may interact with us by one of the following ways: +* open an issue/bug report, feature request or post a question using [Issue Tracker](https://github.com/KudryashevLab/TomoBEAR/issues); +* write an e-mail to [Misha Kudryashev](mailto:misha.kudryashev@gmail.com) or [Artsemi Yushkevich](mailto:Artsemi.Yushkevich@mdc-berlin.de); +* start a discussion in [Discussions](https://github.com/KudryashevLab/TomoBEAR/discussions); + +If you wish to contribute, please, fork this repository and make a pull request back with your changes and a short description. + +## Citation + +If you use `TomoBEAR` or its parts in your research, please **cite both** `TomoBEAR` and **all external software packages** which you have used under `TomoBEAR`. + +The `TomoBEAR` modules dependencies on third-party software are listed on the page [Modules](https://github.com/KudryashevLab/TomoBEAR/wiki/Modules.md) and the list of the corresponding references to cite is located on the page [Additional Software Citation](https://github.com/KudryashevLab/TomoBEAR/wiki/Additional-Software-Citation.md). + +## Acknowledgements We are grateful to the following organizations: - Buchmann family and [BMLS (Buchmann Institute for Molecular Life Sciences)](https://www.bmls.de) for supporting this project with their starters stipendia for PhD students; @@ -43,11 +76,16 @@ We are grateful to the following organizations: As well we are grateful to the [structural biology scientific research group of Werner Kühlbrandt](https://www.biophys.mpg.de/2207989/werner_kuehlbrandt) at the [MPIBP (Max Planck Institute of Biophysics)](https://www.biophys.mpg.de) and the [MPIBP](https://www.biophys.mpg.de) in Frankfurt (Hesse), Germany for support. -# Contacts -[Prof. Dr. Misha Kudryashev (Project Leader)](mailto:misha.kudryashev@gmail.com?subject=[GitHub]%20TomoBEAR) - Principal Investigator, head of the [In situ Structural Biology Group](https://www.mdc-berlin.de/kudryashev) at the [MDCMM (Max Delbrück Center of Molecular Medicine)](https://www.mdc-berlin.de) in Berlin, Germany. +## Contacts +* Prof. Dr. Misha Kudryashev[^1][^2] ([e-mail](mailto:misha.kudryashev@gmail.com?subject=[GitHub]%20TomoBEAR)) - `TomoBEAR` project leader, Principal Investigator; + +* Nikita Balyschew[^2] - `TomoBEAR` core version developer, alumni Ph.D. student. + +* Artsemi Yushkevich[^1] ([e-mail](mailto:Artsemi.Yushkevich@mdc-berlin.de?subject=[GitHub]%20TomoBEAR)) - `TomoBEAR` contributing developer, Ph.D. student. + +* Vasilii Mikirtumov[^1] ([e-mail](mailto:mikivasia@gmail.com?subject=[GitHub]%20TomoBEAR)) - `TomoBEAR` application engineer, Ph.D. student. -[Nikita Balyschew (Developer)](mailto:nikita.balyschew@gmail.com?subject=[GitHub]%20TomoBEAR) - Guest Scientist in the [In situ Structural Biology Group](https://www.mdc-berlin.de/kudryashev) at the [MDCMM (Max Delbrück Center of Molecular Medicine)](https://www.mdc-berlin.de) in Berlin, Germany; alumni Ph.D. student in the [Independent Research Group (Sofja Kovaleskaja)](https://www.biophys.mpg.de/2149775/members) at the Department of Structural Biology at [MPIBP (Max Planck Institute of Biophysics)](https://www.biophys.mpg.de/en) in Frankfurt (Hesse), Germany. -[Artsemi Yushkevich (Contributing Developer)](mailto:Artsemi.Yushkevich@mdc-berlin.de?subject=[GitHub]%20TomoBEAR) - Ph.D. student in the [In situ Structural Biology Group](https://www.mdc-berlin.de/kudryashev) at the [MDCMM (Max Delbrück Center of Molecular Medicine)](https://www.mdc-berlin.de) in Berlin, Germany. +[^1]: [In situ Structural Biology Group](https://www.mdc-berlin.de/kudryashev) at the [MDCMM (Max Delbrück Center of Molecular Medicine)](https://www.mdc-berlin.de) in Berlin, Germany. -[Vasili Mikirtumov (Application Engineer)](mailto:mikivasia@gmail.com?subject=[GitHub]%20TomoBEAR) - Ph.D. student in the [In situ Structural Biology Group](https://www.mdc-berlin.de/kudryashev) at the [MDCMM (Max Delbrück Center of Molecular Medicine)](https://www.mdc-berlin.de) in Berlin, Germany. +[^2]: [Independent Research Group (Sofja Kovaleskaja)](https://www.biophys.mpg.de/2149775/members) at the Department of Structural Biology at [MPIBP (Max Planck Institute of Biophysics)](https://www.biophys.mpg.de/en) in Frankfurt (Hesse), Germany; diff --git a/configuration/ConfigurationParser.m b/configuration/ConfigurationParser.m old mode 100755 new mode 100644 index dd66cd1..a376c37 --- a/configuration/ConfigurationParser.m +++ b/configuration/ConfigurationParser.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef ConfigurationParser < handle properties (Access = private) file_path string; diff --git a/configurations/ctffind_heredoc.sh b/configurations/ctffind_heredoc.sh new file mode 100755 index 0000000..5b4270a --- /dev/null +++ b/configurations/ctffind_heredoc.sh @@ -0,0 +1,19 @@ +${1} << INPUTDATA +${2} +${3} +${4} +${5} +${6} +${7} +${8} +${9} +${10} +${11} +${12} +${13} +no +no +no +no +no +INPUTDATA diff --git a/configurations/defaults.json b/configurations/defaults.json index dc7ce4f..b5c260f 100755 --- a/configurations/defaults.json +++ b/configurations/defaults.json @@ -35,6 +35,7 @@ "wipe_cache": false, "motion_correction_command": "", "ctf_correction_command": "", + "ctffind_heredoc_path": "configurations/ctffind_heredoc.sh", "double_numbering": true, "prefix_position": 0, "tomogram_number_position": -1, @@ -101,7 +102,7 @@ "number_regex": "[_]*([\\d]+[_[\\d]*]*)_", "name_number_regex": "([A-Za-z\\d_]+[A-Za-z]+)[_]*([\\d]+[_[\\d]*]*)", "name_number_regex_backup": "([A-Za-z\\d_]+[A-Za-z]+)[_]*([\\d]+[_[\\d]*]*)_", - "month_date_time_regex": "[_]+([{A-Z}1][{a-z}2]+[\\d]+)_([{\\d}2]+.[{\\d}2]+.[{\\d}2]+)[.]+", + "month_date_time_regex": "_([A-Z][a-z]{2}[\\d]{2})_([\\d]{2}.[\\d]{2}.[\\d]{2})[._]", "tomogram_acquisition_time_in_minutes": 70, "keep_intermediates": true, "reconstruct": "binned", @@ -193,7 +194,8 @@ "dose_weighted_sum_tilt_stacks_folder": "dose_weighted_sum_tilt_stacks", "denoised_binned_tomograms_folder": "denoised_binned_tomograms", "denoised_tilt_stacks_folder": "denoised_tilt_stacks", - "aretomo_command": "" + "aretomo_command": "", + "listening_time_threshold_in_minutes": 15 }, "StopPipeline": { "execution_method": "control" @@ -224,6 +226,11 @@ "use_ctf_corrected_stack": true, "generate_exact_filtered_tomograms": false, "exact_filter_size": 1500, + "generate_nad_filtered_tomograms": false, + "nad_filter_output_iterations_list": [3], + "nad_filter_number_of_iterations": -1, + "nad_filter_sigma_for_smoothing": -1, + "nad_filter_threshold_for_gradients": -1, "use_rawtlt": true, "correct_angles": "center", "skip": false, @@ -331,7 +338,16 @@ "citation_link": "", "doi": "", "do_EPA": true, - "estimated_astigmatism": 1000 + "estimated_astigmatism": 1000, + "ctf_estimation_method": "gctf", + "fourier_spectrum_size": 1024, + "resL": 50, + "resH": 4, + "defL": 5000, + "defH": 90000, + "ctf_preestim_defS": 500, + "ctf_estim_defS": 100, + "ctffind_output_suffix": "ctfestim" }, "RefineFiducialModel": { "execution_method": "sequential", @@ -877,10 +893,12 @@ }, "AreTomo": { "execution_method": "in_order", + "input_stack_binning": 1, "reconstruction": false, "weighted_back_projection": true, "tilt_axis_refine_flag": 1, - "apply_tilt_axis_offset": 0, + "correct_tilt_axis_offset": 0, + "apply_given_tilt_axis_offset": false, "tilt_axis_offset": 0, "align_height_ratio": 0.75, "apply_dose_weighting": false, @@ -910,5 +928,96 @@ "smoothing_exp_decay": -40, "cleaned_postfix": "gef", "relink_as_previous_output": false + }, + "GenerateParticles": { + "execution_method": "once", + "generate_particles_method": "", + "particles_table_path": "", + "box_size": 1.0, + "particles_binning": -1, + "use_SUSAN": false, + "ctf_correction_method": "defocus_file", + "susan_padding": 200, + "per_particle_ctf_correction": "phase_flip", + "padding_policy": "zero", + "normalization": "zm" + }, + "IsoNet": { + "execution_method": "once", + "isonet_env": "", + "repository_path": "", + "tomograms_to_use": [], + "steps_to_execute": {}, + "steps_to_execute_defaults": { + "prepare_star": { + "use_ctf_corrected_tomograms": false, + "add_defocus_to_star": true, + "tomograms_binning": -1, + "folder_name": "tomograms", + "output_star": "tomograms.star", + "number_subtomos": -1 + }, + "deconv": { + "star_file": "tomograms.star", + "deconv_folder": "deconv", + "snrfalloff": 0.7, + "deconvstrength": -1, + "highpassnyquist": -1, + "chunk_size": -1, + "overlap_rate": -1, + "ncpu": -1 + }, + "make_mask": { + "star_file": "tomograms.star", + "mask_folder": "mask", + "patch_size": -1, + "mask_boundary": "", + "density_percentage": 50, + "std_percentage": 50, + "z_crop": -1, + "use_deconv_tomo": true + }, + "extract": { + "star_file": "tomograms.star", + "subtomo_folder": "subtomo", + "subtomo_star": "subtomo.star", + "cube_size": -1, + "crop_size": -1, + "use_deconv_tomo": true + }, + "refine": { + "subtomo_star": "subtomo.star", + "iterations": 30, + "data_dir": "", + "pretrained_model": "", + "result_dir": "results", + "preprocessing_ncpus": -1, + "continue_from": "", + "epochs": -1, + "batch_size": -1, + "steps_per_epoch": -1, + "noise_level": [0.05,0.1,0.15,0.2], + "noise_start_iter": [10,15,20,25], + "noise_mode": "", + "noise_dir": "", + "learning_rate": -1, + "drop_out": -1, + "convs_per_depth": -1, + "kernel": [], + "unet_depth": -1, + "filter_base": -1, + "batch_normalization": -1, + "normalize_percentile": -1 + }, + "predict": { + "star_file": "tomograms.star", + "model": "results/model_iter30.h5", + "output_dir": "corrected_tomos", + "cube_size": -1, + "crop_size": -1, + "batch_size": -1, + "normalize_percentile": -1 + } + } } } diff --git a/environment/concatAndAddPathsRecursive.m b/environment/concatAndAddPathsRecursive.m old mode 100755 new mode 100644 index ae9181f..e1a6902 --- a/environment/concatAndAddPathsRecursive.m +++ b/environment/concatAndAddPathsRecursive.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function concatAndAddPathsRecursive(path, sub_path_list, separator, debug) if nargin == 2 separator = string(filesep); diff --git a/environment/initializeEnvironment.m b/environment/initializeEnvironment.m old mode 100755 new mode 100644 index 30de9c6..bff11d8 --- a/environment/initializeEnvironment.m +++ b/environment/initializeEnvironment.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function initializeEnvironment(default_configuration_path) if ~isdeployed() addpath("configuration"); diff --git a/images/TomoBEAR_gitlogo.png b/images/TomoBEAR_gitlogo.png new file mode 100644 index 0000000..61ad6cc Binary files /dev/null and b/images/TomoBEAR_gitlogo.png differ diff --git a/images/pipeline_simplified.png b/images/pipeline_simplified.png new file mode 100644 index 0000000..6077f07 Binary files /dev/null and b/images/pipeline_simplified.png differ diff --git a/json/JSON.m b/json/JSON.m old mode 100755 new mode 100644 index 557269d..c20f871 --- a/json/JSON.m +++ b/json/JSON.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef JSON < handle properties end diff --git a/modules/AreTomo.m b/modules/AreTomo.m index 2191a48..d6fd662 100644 --- a/modules/AreTomo.m +++ b/modules/AreTomo.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % https://drive.google.com/drive/folders/1Z7pKVEdgMoNaUmd_cOFhlt-QCcfcwF3_ classdef AreTomo < Module methods @@ -10,8 +29,14 @@ end function obj = process(obj) - tilt_stacks = getTiltStacksFromStandardFolder(obj.configuration, true); - + + if obj.configuration.input_stack_binning > 1 + tilt_stacks = getBinnedTiltStacksFromStandardFolder(obj.configuration, true); + tilt_stacks = tilt_stacks(contains({tilt_stacks.name}, "bin_" + num2str(obj.configuration.input_stack_binning))); + else + tilt_stacks = getTiltStacksFromStandardFolder(obj.configuration, true); + end + % if isfield(obj.configuration.tomograms.(obj.field_names{obj.configuration.set_up.j}), "motion_corrected_odd_files") % even_tilt_stacks = getEvenTiltStacksFromStandardFolder(obj.configuration, true); % odd_tilt_stacks = getOddTiltStacksFromStandardFolder(obj.configuration, true); @@ -53,14 +78,20 @@ %angle_command_snippet = "-TiltRange " + min_and_max_tilt_angles(1) + " " + min_and_max_tilt_angles(end); if obj.configuration.patch ~= "0 0" + local_ali = true; patch_alignment_command_snippet = "-Patch " + strjoin(obj.configuration.patch," "); else + local_ali = false; patch_alignment_command_snippet = ""; end tilt_axis_command_snippet = "-TiltAxis " + num2str(obj.configuration.rotation_tilt_axis) + " " + num2str(obj.configuration.tilt_axis_refine_flag); - tilt_axis_offset_command_snippet = "-TiltCor " + num2str(obj.configuration.apply_tilt_axis_offset) + " " + num2str(obj.configuration.tilt_axis_offset); + if obj.configuration.apply_given_tilt_axis_offset == true + tilt_axis_offset_command_snippet = "-TiltCor " + num2str(obj.configuration.correct_tilt_axis_offset) + " " + num2str(obj.configuration.tilt_axis_offset); + else + tilt_axis_offset_command_snippet = ""; + end if obj.configuration.set_up.gpu > 0 gpu_number = obj.configuration.set_up.gpu - 1; @@ -68,6 +99,11 @@ error("ERROR: Gpus are needed to run this module!"); end + if obj.configuration.aligned_stack_binning < obj.configuration.input_stack_binning + error("ERROR: Requested aligned_stack_binning (=" + num2str(obj.configuration.aligned_stack_binning)... + + ") is lower than required input_stack_binning (=" + num2str(obj.configuration.input_stack_binning) + ") !"); + end + stack_source = string(tilt_stacks(obj.configuration.set_up.adjusted_j).folder) + string(filesep) + string(tilt_stacks(obj.configuration.set_up.adjusted_j).name); % Generate aligned stack of the requested binning level @@ -75,14 +111,15 @@ executeCommand(obj.configuration.aretomo_command... + " -InMrc " + stack_source... + " -OutMrc " + stack_destination... - + " -VolZ 0 -OutBin " + num2str(obj.configuration.aligned_stack_binning)... + + " -VolZ 0 -OutBin " + num2str(obj.configuration.aligned_stack_binning / obj.configuration.input_stack_binning)... + " -Gpu " + num2str(gpu_number) + " "... + angular_file_command_snippet + " "... + tilt_axis_command_snippet + " "... + tilt_axis_offset_command_snippet + " "... + patch_alignment_command_snippet... - + "-OutImod 1", false, obj.log_file_id); + + " -OutImod 1", false, obj.log_file_id); + % NOTE: rename ALN file [~,filename,fileext] = fileparts(stack_source); alignment_file_out = obj.output_path + filesep + filename + fileext + ".aln"; alignment_file_destination = obj.output_path + filesep + obj.name + ".aln"; @@ -105,32 +142,71 @@ mkdir(path_destination); createSymbolicLink(stack_destination, link_destination, obj.log_file_id); - % Move IMOD-compatible files one level up + % NOTE: Move IMOD-compatible files one level up imod_folder = obj.output_path + filesep + obj.name + ".ali_Imod"; - if exist(imod_folder, 'dir') - movefile(imod_folder + filesep + "*", obj.output_path); + if isfolder(imod_folder) + imod_files = dir(imod_folder + string(filesep) + obj.name + "*.*"); + for file_id = 1:length(imod_files) + imod_file_out = imod_files(file_id).folder + string(filesep) + imod_files(file_id).name; + [~, ~, imod_file_ext] = fileparts(imod_file_out); + imod_file_destination = obj.output_path + filesep + obj.name + imod_file_ext; + movefile(imod_file_out, imod_file_destination); + end end - % Generate aligned unbinned stack using alignment parameters - % previously detected at the requested binning level + % NOTE: GENERATE UNBINNED ALIGNED STACK + + % Get list of views to exclude according to aligned stack xf_file = dir(obj.output_path + filesep + obj.name + ".xf"); xf_file_path = xf_file(1).folder + string(filesep) + xf_file(1).name; - [~, size_to_output] = system("header -s " + stack_source); - size_to_output = str2num(size_to_output); - + fid = fopen(xf_file_path, 'rt'); + txt = textscan(fid, '%s', 'Delimiter', '\n'); + fclose(fid); + + txt = txt{1}(~cellfun(@isempty, txt{1})); + % NOTE: dirty! rewrite using regexp or other search patterns + unit_transform_string = '1.000 0.000 0.000 1.000 0.00 0.00'; + exclude_mask = contains(txt, unit_transform_string); + exclude_views = find(exclude_mask); + exclude_views = exclude_views'; + + % Generate aligned unbinned stack using alignment parameters + % previously detected at the requested binning level + tilt_stacks = getTiltStacksFromStandardFolder(obj.configuration, true); + stack_source = string(tilt_stacks(obj.configuration.set_up.adjusted_j).folder) + string(filesep) + string(tilt_stacks(obj.configuration.set_up.adjusted_j).name); stack_destination_unbinned = obj.output_path + filesep + obj.name + "_bin_" + num2str(1) + ".ali"; - status = system("newstack -InputFile " + stack_source... - + " -OutputFile " + stack_destination_unbinned... - + " -TransformFile " + xf_file_path... - + " -OffsetsInXandY 0.0,0.0 -BinByFactor 1 -ImagesAreBinned 1.0 -AdjustOrigin"... - + " -SizeToOutputInXandY " + num2str(size_to_output(2)) + "," + num2str(size_to_output(1))... - + " -TaperAtFill 1,0"); + aln_file = dir(obj.output_path + filesep + obj.name + ".aln"); + aln_file_path = aln_file(1).folder + string(filesep) + aln_file(1).name; + + executeCommand(obj.configuration.aretomo_command... + + " -InMrc " + stack_source... + + " -OutMrc " + stack_destination_unbinned... + + " -VolZ 0 -OutBin 1"... + + " -Gpu " + num2str(gpu_number) + " "... + + " -AlnFile " + aln_file_path... + + " -OutImod 0", false, obj.log_file_id); + +% [~, size_to_output] = system("header -s " + stack_source); +% size_to_output = str2num(size_to_output); +% +% status = system("newstack -InputFile " + stack_source... +% + " -OutputFile " + stack_destination_unbinned... +% + " -TransformFile " + xf_file_path... +% + " -OffsetsInXandY 0.0,0.0 -BinByFactor 1 -ImagesAreBinned 1.0 -AdjustOrigin"... +% + " -SizeToOutputInXandY " + num2str(size_to_output(2)) + "," + num2str(size_to_output(1))... +% + " -TaperAtFill 1,0"); + + % Exclude views from generated unbinned stack + if ~isempty(exclude_views) + status = system("excludeviews -StackName " + stack_destination_unbinned... + + " -ViewsToExclude " + strjoin(string(exclude_views), ',')); + end folder_destination = obj.configuration.aligned_tilt_stacks_folder; filename_link_destination = obj.name + "_bin_" + num2str(1) + ".ali"; - + path_destination = obj.configuration.processing_path + filesep + obj.configuration.output_folder + filesep + folder_destination + filesep + obj.name; link_destination = path_destination + filesep + filename_link_destination; if exist(path_destination, "dir") @@ -139,6 +215,26 @@ mkdir(path_destination); createSymbolicLink(stack_destination_unbinned, link_destination, obj.log_file_id); + % Write unit transform matrix if local ali was applied + if local_ali == true + xf_file = dir(obj.output_path + filesep + obj.name + ".xf"); + xf_file_path = xf_file(1).folder + string(filesep) + xf_file(1).name; + + if isfile(xf_file_path) + delete(xf_file_path); + end + + fid = fopen(xf_file_path, 'w'); + + [~, size_to_output] = system("header -s " + stack_source); + num_views_keep = str2num(size_to_output); + num_views_keep = num_views_keep(3); + for i=1:num_views_keep + fprintf(fid, "%s\n", unit_transform_string); + end + fclose(fid); + end + %TODO: provide the same data as after fiducial-based alignment %to make user experience smooth (check whether need code below) % for i = 1:length(obj.configuration.binnings) diff --git a/modules/BatchRunTomo.m b/modules/BatchRunTomo.m old mode 100755 new mode 100644 index 7cb8f30..7d73b20 --- a/modules/BatchRunTomo.m +++ b/modules/BatchRunTomo.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % NOTE: https://bio3d.colorado.edu/imod/betaDoc/alignframesGuide.html % NOTE: https://bio3d.colorado.edu/imod/download.html classdef BatchRunTomo < Module @@ -665,8 +684,10 @@ % fprintf(fileID, "%0.2f\n", angles(i)); % end % fclose(fileID); - elseif obj.configuration.starting_step == 0 && obj.configuration.ending_step == 3 && ~fileExists(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.fid_files_folder + string(filesep) + splitted_name{1} + string(filesep) + splitted_name{1} + ".fid") - obj.configuration.ending_step = 5; + % NOTE: commented out lines below because otherwise + % patch tracking-based alignment is impossible + %elseif obj.configuration.starting_step == 0 && obj.configuration.ending_step == 3 && ~fileExists(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.fid_files_folder + string(filesep) + splitted_name{1} + string(filesep) + splitted_name{1} + ".fid") + % obj.configuration.ending_step = 5; %obj.dynamic_configuration.ending_step = obj.configuration.ending_step; %disp("INFO: updated ending step to step " + obj.dynamic_configuration.ending_step + " due to incorrect DynamoTiltSeriesAlignment!"); end @@ -732,64 +753,85 @@ [folder, name, extension] = fileparts(dir_list(i).name); tilt_stack_file_path = string(dir_list(i).folder) + string(filesep) + string(dir_list(i).name); - if obj.configuration.ending_step >= 8 - if obj.configuration.aligned_stack_binning > 1 - [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.ctf_corrected_binned_aligned_tilt_stacks_folder + string(filesep) + name); - if fileExists(current_location + string(filesep) + name + "_ali.mrc") - createSymbolicLink(current_location + string(filesep) + name + "_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.ctf_corrected_binned_aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + "_bin_" + obj.configuration.aligned_stack_binning + ".ali", obj.log_file_id); + if obj.configuration.aligned_stack_binning > 1 + if obj.configuration.ending_step == 8 + % link binned aligned tilt stacks before + % creating unbinned aligned tilt stacks + [folder, name, extension] = fileparts(dir_list(i).name); + [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.binned_aligned_tilt_stacks_folder + string(filesep) + name); + if fileExists(current_location + string(filesep) + name + ".ali") + createSymbolicLink(current_location + string(filesep) + name + ".ali", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.binned_aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + "_bin_" + obj.configuration.aligned_stack_binning + ".ali", obj.log_file_id); else - createSymbolicLink(current_location + string(filesep) + name + ".ali", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.ctf_corrected_binned_aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + "_bin_" + obj.configuration.aligned_stack_binning + ".ali", obj.log_file_id); + createSymbolicLink(current_location + string(filesep) + name + "_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.binned_aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + "_bin_" + obj.configuration.aligned_stack_binning + ".ali", obj.log_file_id); end - if obj.configuration.ending_step == 8 - xf_file = dir(current_location + string(filesep) + name + ".xf"); - [status, command_output] = system("header -s " + tilt_stack_file_path); - command_output = str2num(command_output); - status = system("newstack -InputFile " + tilt_stack_file_path... - + " -OutputFile " + current_location + string(filesep) + name + "_bin_" + num2str(1) + ".ali -TransformFile "... + + xf_file = dir(current_location + string(filesep) + name + ".xf"); + [status, command_output] = system("header -s " + tilt_stack_file_path); + command_output = str2num(command_output); + status = system("newstack -InputFile " + tilt_stack_file_path... + + " -OutputFile " + current_location + string(filesep) + name + "_bin_" + num2str(1) + ".ali -TransformFile "... + + xf_file(i).folder + string(filesep) + xf_file(i).name + " -OffsetsInXandY 0.0,0.0 -BinByFactor 1 -ImagesAreBinned 1.0 -AdjustOrigin -SizeToOutputInXandY "... + + num2str(command_output(2)) + "," + num2str(command_output(1)) + " -TaperAtFill 1,0"); + [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_tilt_stacks_folder + string(filesep) + name); + if fileExists(current_location + string(filesep) + name + "_bin_" + num2str(1) + ".ali") + createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + ".ali", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); + else + createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + "_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); + end + + if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_even_files") + even_tilt_stacks = getEvenTiltStacksFromStandardFolder(obj.configuration, true); + status = system("newstack -InputFile " + even_tilt_stacks(obj.configuration.set_up.adjusted_j).folder + filesep + even_tilt_stacks(obj.configuration.set_up.adjusted_j).name... + + " -OutputFile " + current_location + string(filesep) + name + "_bin_" + num2str(1) + "_even.ali -TransformFile "... + xf_file(i).folder + string(filesep) + xf_file(i).name + " -OffsetsInXandY 0.0,0.0 -BinByFactor 1 -ImagesAreBinned 1.0 -AdjustOrigin -SizeToOutputInXandY "... + num2str(command_output(2)) + "," + num2str(command_output(1)) + " -TaperAtFill 1,0"); - [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_tilt_stacks_folder + string(filesep) + name); + [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_even_tilt_stacks_folder + string(filesep) + name); if fileExists(current_location + string(filesep) + name + "_bin_" + num2str(1) + ".ali") - createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + ".ali", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); + createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + "_even.ali", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_even_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); else - createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + "_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); + createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + "_even_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_even_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); end - - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_even_files") - even_tilt_stacks = getEvenTiltStacksFromStandardFolder(obj.configuration, true); - status = system("newstack -InputFile " + even_tilt_stacks(obj.configuration.set_up.adjusted_j).folder + filesep + even_tilt_stacks(obj.configuration.set_up.adjusted_j).name... - + " -OutputFile " + current_location + string(filesep) + name + "_bin_" + num2str(1) + "_even.ali -TransformFile "... - + xf_file(i).folder + string(filesep) + xf_file(i).name + " -OffsetsInXandY 0.0,0.0 -BinByFactor 1 -ImagesAreBinned 1.0 -AdjustOrigin -SizeToOutputInXandY "... - + num2str(command_output(2)) + "," + num2str(command_output(1)) + " -TaperAtFill 1,0"); - [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_even_tilt_stacks_folder + string(filesep) + name); - if fileExists(current_location + string(filesep) + name + "_bin_" + num2str(1) + ".ali") - createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + "_even.ali", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_even_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); - else - createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + "_even_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_even_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); - end - - odd_tilt_stacks = getOddTiltStacksFromStandardFolder(obj.configuration, true); - status = system("newstack -InputFile " + odd_tilt_stacks(obj.configuration.set_up.adjusted_j).folder + filesep + odd_tilt_stacks(obj.configuration.set_up.adjusted_j).name... - + " -OutputFile " + current_location + string(filesep) + name + "_bin_" + num2str(1) + "_odd.ali -TransformFile "... - + xf_file(i).folder + string(filesep) + xf_file(i).name + " -OffsetsInXandY 0.0,0.0 -BinByFactor 1 -ImagesAreBinned 1.0 -AdjustOrigin -SizeToOutputInXandY "... - + num2str(command_output(2)) + "," + num2str(command_output(1)) + " -TaperAtFill 1,0"); - [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_odd_tilt_stacks_folder + string(filesep) + name); - if fileExists(current_location + string(filesep) + name + "_bin_" + num2str(1) + ".ali") - createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + "_odd.ali", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_odd_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); - else - createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + "_odd_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_odd_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); - end + + odd_tilt_stacks = getOddTiltStacksFromStandardFolder(obj.configuration, true); + status = system("newstack -InputFile " + odd_tilt_stacks(obj.configuration.set_up.adjusted_j).folder + filesep + odd_tilt_stacks(obj.configuration.set_up.adjusted_j).name... + + " -OutputFile " + current_location + string(filesep) + name + "_bin_" + num2str(1) + "_odd.ali -TransformFile "... + + xf_file(i).folder + string(filesep) + xf_file(i).name + " -OffsetsInXandY 0.0,0.0 -BinByFactor 1 -ImagesAreBinned 1.0 -AdjustOrigin -SizeToOutputInXandY "... + + num2str(command_output(2)) + "," + num2str(command_output(1)) + " -TaperAtFill 1,0"); + [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_odd_tilt_stacks_folder + string(filesep) + name); + if fileExists(current_location + string(filesep) + name + "_bin_" + num2str(1) + ".ali") + createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + "_odd.ali", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_odd_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); + else + createSymbolicLink(current_location + string(filesep) + name + "_bin_" + num2str(1) + "_odd_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_odd_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); end end - else + elseif obj.configuration.ending_step > 8 + [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.ctf_corrected_binned_aligned_tilt_stacks_folder + string(filesep) + name); + if fileExists(current_location + string(filesep) + name + "_ali.mrc") + createSymbolicLink(current_location + string(filesep) + name + "_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.ctf_corrected_binned_aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + "_bin_" + obj.configuration.aligned_stack_binning + ".ali", obj.log_file_id); + else + createSymbolicLink(current_location + string(filesep) + name + ".ali", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.ctf_corrected_binned_aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + "_bin_" + obj.configuration.aligned_stack_binning + ".ali", obj.log_file_id); + end + end + else + if obj.configuration.ending_step == 8 [folder, name, extension] = fileparts(dir_list(i).name); - if fileExists(obj.configuration, current_location + string(filesep) + name + ".ali") - createSymbolicLinkInStandardFolder(obj.configuration, current_location + string(filesep) + name + ".ali", "ctf_corrected_aligned_tilt_stacks_folder", obj.log_file_id); + [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_tilt_stacks_folder + string(filesep) + name); + if fileExists(current_location + string(filesep) + name + ".ali") + createSymbolicLink(current_location + string(filesep) + name + ".ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); else - createSymbolicLinkInStandardFolder(obj.configuration, current_location + string(filesep) + name + "_ali.mrc", "ctf_corrected_aligned_tilt_stacks_folder", obj.log_file_id); + createSymbolicLink(current_location + string(filesep) + name + "_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); + end + elseif obj.configuration.ending_step > 8 + [folder, name, extension] = fileparts(dir_list(i).name); + [success, message, message_id] = mkdir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.ctf_corrected_aligned_tilt_stacks_folder + string(filesep) + name); + if fileExists(current_location + string(filesep) + name + ".ali") + createSymbolicLink(current_location + string(filesep) + name + ".ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.ctf_corrected_aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); + else + createSymbolicLink(current_location + string(filesep) + name + "_ali.mrc", obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.ctf_corrected_aligned_tilt_stacks_folder + string(filesep) + name + string(filesep) + name + ".ali", obj.log_file_id); end end end + % TODO:NOTE: infact step 21 if obj.configuration.ending_step > 14 if fileExists(obj.configuration, current_location + string(filesep) + name + ".rec") diff --git a/modules/BinStacks.m b/modules/BinStacks.m old mode 100755 new mode 100644 index fcf78f1..9c102a0 --- a/modules/BinStacks.m +++ b/modules/BinStacks.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef BinStacks < Module methods function obj = BinStacks(configuration) @@ -64,11 +83,9 @@ return; end - xf_file_paths = getFilePathsFromLastBatchruntomoRun(obj.configuration, "xf"); - [path, name, extension] = fileparts(tilt_stacks.name); - xf_file_source = xf_file_paths{1}; + xf_file_source = getXfOrAlnFilePaths(obj.configuration, obj.output_path, obj.name); xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; @@ -163,39 +180,57 @@ obj.status = 0; return; end - - xf_file_paths = getFilePathsFromLastBatchruntomoRun(obj.configuration, "xf"); - + [path, name, extension] = fileparts(tilt_stacks.name); - - xf_file_source = xf_file_paths{1}; - - xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; - - obj.temporary_files(end + 1) = createSymbolicLink(xf_file_source, xf_file_destination, obj.log_file_id); - + + if obj.configuration.use_ctf_corrected_aligned_stack == true || obj.configuration.use_aligned_stack == true + xf_file_source = getXfOrAlnFilePaths(obj.configuration, obj.output_path, obj.name); + xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; + obj.temporary_files(end + 1) = createSymbolicLink(xf_file_source, xf_file_destination, obj.log_file_id); + xform_command_snippet = " -xform " + xf_file_destination; + stk_bin_ext = ".ali"; + else + xform_command_snippet = ""; + stk_bin_ext = ".st"; + end + stack_source = tilt_stacks.folder + string(filesep) + tilt_stacks.name; stack_destination = obj.output_path + string(filesep) + name + ".st"; obj.temporary_files(end + 1) = createSymbolicLink(stack_source, stack_destination, obj.log_file_id); % for j = 1:length(obj.configuration.binnings) binned_stack_suffix = "bin_" + num2str(obj.configuration.binnings(i)); - disp("INFO: Creating " + name + "_" + binned_stack_suffix + ".ali..."); - stack_output_path = obj.output_path + string(filesep) + name + "_" + binned_stack_suffix + ".ali"; + + disp("INFO: Creating " + name + "_" + binned_stack_suffix + stk_bin_ext + "..."); + stack_output_path = obj.output_path + string(filesep) + name + "_" + binned_stack_suffix + stk_bin_ext; + obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).binned_stacks{i} = stack_output_path; [width, height, z] = getHeightAndWidthFromHeader(stack_destination, -1); + executeCommand("newstack"... + " -size " + floor(height / (obj.configuration.binnings(i) / obj.configuration.ft_bin)) + "," + floor(width / (obj.configuration.binnings(i) / obj.configuration.ft_bin))... + " -input " + stack_destination... + " -output " + stack_output_path... - + " -xform " + xf_file_destination... + ...%+ " -xform " + xf_file_destination... + + xform_command_snippet... + " -antialias " + obj.configuration.antialias_filter... + " -bin " + num2str(bin_factor), false, obj.log_file_id); executeCommand("alterheader -del " + apix + "," + apix + "," + apix + "," + " " + stack_output_path, false, obj.log_file_id); + if obj.configuration.binnings(i) > 1 - [output_binned_stacks_symbolic_links, obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).binned_stacks_symbolic_links{i}] = createSymbolicLinkInStandardFolder(obj.configuration, stack_output_path, "binned_aligned_tilt_stacks_folder", obj.log_file_id); + if obj.configuration.use_ctf_corrected_aligned_stack == true || obj.configuration.use_aligned_stack == true + slink_dir = "binned_aligned_tilt_stacks_folder"; + else + slink_dir = "binned_tilt_stacks_folder"; + end + [output_binned_stacks_symbolic_links, obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).binned_stacks_symbolic_links{i}] = createSymbolicLinkInStandardFolder(obj.configuration, stack_output_path, slink_dir, obj.log_file_id); else - [output_stacks_symbolic_links, obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).stacks_symbolic_links{i}] = createSymbolicLinkInStandardFolder(obj.configuration, stack_output_path, "aligned_tilt_stacks_folder", obj.log_file_id); + if obj.configuration.use_ctf_corrected_aligned_stack == true || obj.configuration.use_aligned_stack == true + slink_dir = "aligned_tilt_stacks_folder"; + else + slink_dir = "tilt_stacks_folder"; + end + [output_stacks_symbolic_links, obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).stacks_symbolic_links{i}] = createSymbolicLinkInStandardFolder(obj.configuration, stack_output_path, slink_dir, obj.log_file_id); end if obj.configuration.run_ctf_phaseflip == true @@ -280,32 +315,35 @@ obj.status = 0; return; end - - xf_file_paths = getFilePathsFromLastBatchruntomoRun(obj.configuration, "xf"); - + [path, name, extension] = fileparts(tilt_stacks.name); - - xf_file_source = xf_file_paths{1}; - - xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; - - obj.temporary_files(end + 1) = createSymbolicLink(xf_file_source, xf_file_destination, obj.log_file_id); - + if obj.configuration.use_ctf_corrected_aligned_stack == true || obj.configuration.use_aligned_stack == true + xf_file_source = getXfOrAlnFilePaths(obj.configuration, obj.output_path, obj.name); + xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; + obj.temporary_files(end + 1) = createSymbolicLink(xf_file_source, xf_file_destination, obj.log_file_id); + xform_command_snippet = " -xform " + xf_file_destination; + stk_bin_ext = ".ali"; + else + xform_command_snippet = ""; + stk_bin_ext = ".st"; + end + stack_source = tilt_stacks.folder + string(filesep) + tilt_stacks.name; stack_destination = obj.output_path + string(filesep) + name + "_even.st"; obj.temporary_files(end + 1) = createSymbolicLink(stack_source, stack_destination, obj.log_file_id); % for j = 1:length(obj.configuration.binnings) binned_stack_suffix = "bin_" + num2str(obj.configuration.binnings(i)); - disp("INFO: Creating " + name + "_" + binned_stack_suffix + "_even.ali..."); - stack_output_path = obj.output_path + string(filesep) + name + "_" + binned_stack_suffix + "_even.ali"; + disp("INFO: Creating " + name + "_" + binned_stack_suffix + "_even" + stk_bin_ext + "..."); + stack_output_path = obj.output_path + string(filesep) + name + "_" + binned_stack_suffix + "_even" + stk_bin_ext; obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).binned_stacks{i} = stack_output_path; [width, height, z] = getHeightAndWidthFromHeader(stack_destination, -1); executeCommand("newstack"... + " -size " + floor(height / (obj.configuration.binnings(i) / obj.configuration.ft_bin)) + "," + floor(width / (obj.configuration.binnings(i) / obj.configuration.ft_bin))... + " -input " + stack_destination... + " -output " + stack_output_path... - + " -xform " + xf_file_destination... + ...#+ " -xform " + xf_file_destination... + + xform_command_snippet... + " -antialias " + obj.configuration.antialias_filter... + " -bin " + num2str(bin_factor), false, obj.log_file_id); @@ -385,16 +423,18 @@ obj.status = 0; return; end - - xf_file_paths = getFilePathsFromLastBatchruntomoRun(obj.configuration, "xf"); - + [path, name, extension] = fileparts(tilt_stacks.name); - - xf_file_source = xf_file_paths{1}; - - xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; - - obj.temporary_files(end + 1) = createSymbolicLink(xf_file_source, xf_file_destination, obj.log_file_id); + if obj.configuration.use_ctf_corrected_aligned_stack == true || obj.configuration.use_aligned_stack == true + xf_file_source = getXfOrAlnFilePaths(obj.configuration, obj.output_path, obj.name); + xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; + obj.temporary_files(end + 1) = createSymbolicLink(xf_file_source, xf_file_destination, obj.log_file_id); + xform_command_snippet = " -xform " + xf_file_destination; + stk_bin_ext = ".ali"; + else + xform_command_snippet = ""; + stk_bin_ext = ".st"; + end stack_source = tilt_stacks.folder + string(filesep) + tilt_stacks.name; stack_destination = obj.output_path + string(filesep) + name + "_odd.st"; @@ -402,15 +442,16 @@ % for j = 1:length(obj.configuration.binnings) binned_stack_suffix = "bin_" + num2str(obj.configuration.binnings(i)); - disp("INFO: Creating " + name + "_" + binned_stack_suffix + "_odd.ali..."); - stack_output_path = obj.output_path + string(filesep) + name + "_" + binned_stack_suffix + "_odd.ali"; + disp("INFO: Creating " + name + "_" + binned_stack_suffix + "_odd" + stk_bin_ext + "..."); + stack_output_path = obj.output_path + string(filesep) + name + "_" + binned_stack_suffix + "_odd" + stk_bin_ext; obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).binned_stacks{i} = stack_output_path; [width, height, z] = getHeightAndWidthFromHeader(stack_destination, -1); executeCommand("newstack"... + " -size " + floor(height / (obj.configuration.binnings(i) / obj.configuration.ft_bin)) + "," + floor(width / (obj.configuration.binnings(i) / obj.configuration.ft_bin))... + " -input " + stack_destination... + " -output " + stack_output_path... - + " -xform " + xf_file_destination... + ...#+ " -xform " + xf_file_destination... + + xform_command_snippet... + " -antialias " + obj.configuration.antialias_filter... + " -bin " + num2str(bin_factor), false, obj.log_file_id); executeCommand("alterheader -del " + apix + "," + apix + "," + apix + "," + " " + stack_output_path, false, obj.log_file_id); @@ -488,31 +529,34 @@ return; end - xf_file_paths = getFilePathsFromLastBatchruntomoRun(obj.configuration, "xf"); - [path, name, extension] = fileparts(tilt_stacks.name); - - xf_file_source = xf_file_paths{1}; - - xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; - - obj.temporary_files(end + 1) = createSymbolicLink(xf_file_source, xf_file_destination, obj.log_file_id); - + if obj.configuration.use_ctf_corrected_aligned_stack == true || obj.configuration.use_aligned_stack == true + xf_file_source = getXfOrAlnFilePaths(obj.configuration, obj.output_path, obj.name); + xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; + obj.temporary_files(end + 1) = createSymbolicLink(xf_file_source, xf_file_destination, obj.log_file_id); + xform_command_snippet = " -xform " + xf_file_destination; + stk_bin_ext = ".ali"; + else + xform_command_snippet = ""; + stk_bin_ext = ".st"; + end + stack_source = tilt_stacks.folder + string(filesep) + tilt_stacks.name; stack_destination = obj.output_path + string(filesep) + name + "_dw.st"; obj.temporary_files(end + 1) = createSymbolicLink(stack_source, stack_destination, obj.log_file_id); % for j = 1:length(obj.configuration.binnings) binned_stack_suffix = "bin_" + num2str(obj.configuration.binnings(i)); - disp("INFO: Creating " + name + "_" + binned_stack_suffix + "_dw.ali..."); - stack_output_path = obj.output_path + string(filesep) + name + "_" + binned_stack_suffix + "_dw.ali"; + disp("INFO: Creating " + name + "_" + binned_stack_suffix + "_dw" + stk_bin_ext + "..."); + stack_output_path = obj.output_path + string(filesep) + name + "_" + binned_stack_suffix + "_dw" + stk_bin_ext; obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).binned_stacks{i} = stack_output_path; [width, height, z] = getHeightAndWidthFromHeader(stack_destination, -1); executeCommand("newstack"... + " -size " + floor(height / (obj.configuration.binnings(i) / obj.configuration.ft_bin)) + "," + floor(width / (obj.configuration.binnings(i) / obj.configuration.ft_bin))... + " -input " + stack_destination... + " -output " + stack_output_path... - + " -xform " + xf_file_destination... + ...#+ " -xform " + xf_file_destination... + + xform_command_snippet... + " -antialias " + obj.configuration.antialias_filter... + " -bin " + num2str(bin_factor), false, obj.log_file_id); executeCommand("alterheader -del " + apix + "," + apix + "," + apix + "," + " " + stack_output_path, false, obj.log_file_id); @@ -571,32 +615,36 @@ obj.status = 0; return; end - - xf_file_paths = getFilePathsFromLastBatchruntomoRun(obj.configuration, "xf"); - + + [path, name, extension] = fileparts(tilt_stacks.name); - - xf_file_source = xf_file_paths{1}; - - xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; - - obj.temporary_files(end + 1) = createSymbolicLink(xf_file_source, xf_file_destination, obj.log_file_id); - + if obj.configuration.use_ctf_corrected_aligned_stack == true || obj.configuration.use_aligned_stack == true + xf_file_source = getXfOrAlnFilePaths(obj.configuration, obj.output_path, obj.name); + xf_file_destination = obj.output_path + string(filesep) + name + ".xf"; + obj.temporary_files(end + 1) = createSymbolicLink(xf_file_source, xf_file_destination, obj.log_file_id); + xform_command_snippet = " -xform " + xf_file_destination; + stk_bin_ext = ".ali"; + else + xform_command_snippet = ""; + stk_bin_ext = ".st"; + end + stack_source = tilt_stacks.folder + string(filesep) + tilt_stacks.name; stack_destination = obj.output_path + string(filesep) + name + "_dws.st"; obj.temporary_files(end + 1) = createSymbolicLink(stack_source, stack_destination, obj.log_file_id); % for j = 1:length(obj.configuration.binnings) binned_stack_suffix = "bin_" + num2str(obj.configuration.binnings(i)); - disp("INFO: Creating " + name + "_" + binned_stack_suffix + "_dws.ali..."); - stack_output_path = obj.output_path + string(filesep) + name + "_" + binned_stack_suffix + "_dws.ali"; + disp("INFO: Creating " + name + "_" + binned_stack_suffix + "_dws" + stk_bin_ext + "..."); + stack_output_path = obj.output_path + string(filesep) + name + "_" + binned_stack_suffix + "_dws" + stk_bin_ext; obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).binned_stacks{i} = stack_output_path; [width, height, z] = getHeightAndWidthFromHeader(stack_destination, -1); executeCommand("newstack"... + " -size " + floor(height / (obj.configuration.binnings(i) / obj.configuration.ft_bin)) + "," + floor(width / (obj.configuration.binnings(i) / obj.configuration.ft_bin))... + " -input " + stack_destination... + " -output " + stack_output_path... - + " -xform " + xf_file_destination... + ...#+ " -xform " + xf_file_destination... + + xform_command_snippet... + " -antialias " + obj.configuration.antialias_filter... + " -bin " + num2str(bin_factor), false, obj.log_file_id); executeCommand("alterheader -del " + apix + "," + apix + "," + apix + "," + " " + stack_output_path, false, obj.log_file_id); diff --git a/modules/CreateStacks.m b/modules/CreateStacks.m old mode 100755 new mode 100644 index da9cf10..de77e0c --- a/modules/CreateStacks.m +++ b/modules/CreateStacks.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef CreateStacks < Module methods function obj = CreateStacks(configuration) @@ -399,7 +418,7 @@ % here because might be used on the DynamoCleanStacks step! %obj.temporary_files = output_stack_list; - if length(output_stack_list) < obj.configuration.minimum_files + if (~isfield(obj.configuration, "live_data_mode") || ~obj.configuration.live_data_mode) && (length(output_stack_list) < obj.configuration.minimum_files) disp("INFO: Not enough MRC files to create stack!"); obj.status = 0; return; diff --git a/modules/CryoCARE.m b/modules/CryoCARE.m index 9061c64..72ebe25 100644 --- a/modules/CryoCARE.m +++ b/modules/CryoCARE.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % NOTE: https://arxiv.org/pdf/1810.05420.pdf % NOTE: https://github.com/juglab/cryoCARE_pip diff --git a/modules/DeepFinder.m b/modules/DeepFinder.m index 417d17f..bec2624 100644 --- a/modules/DeepFinder.m +++ b/modules/DeepFinder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef DeepFinder < Module methods function obj = DeepFinder(configuration) diff --git a/modules/DynamoAlignmentProject.m b/modules/DynamoAlignmentProject.m old mode 100755 new mode 100644 index a7e1096..15a1b90 --- a/modules/DynamoAlignmentProject.m +++ b/modules/DynamoAlignmentProject.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef DynamoAlignmentProject < Module methods diff --git a/modules/DynamoCleanStacks.m b/modules/DynamoCleanStacks.m old mode 100755 new mode 100644 index f03df7f..4d7af6a --- a/modules/DynamoCleanStacks.m +++ b/modules/DynamoCleanStacks.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef DynamoCleanStacks < Module methods function obj = DynamoCleanStacks(configuration) @@ -101,7 +120,7 @@ obj.dynamic_configuration.tilt_index_angle_mapping.(name)(4,:) = cumsum(obj.dynamic_configuration.tilt_index_angle_mapping.(name)(3,:)); obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).modified_tilt_stack_path = tilt_stack_destination; obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).modified_tilt_stack_symbolink_link = createSymbolicLinkInStandardFolder(obj.configuration, tilt_stack_destination, "tilt_stacks_folder", obj.log_file_id); - if obj.configuration.keep_intermediates == false + if obj.configuration.execute == false && obj.configuration.keep_intermediates == false delete(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}).tilt_stack_path); end if obj.configuration.show_truncated_stacks diff --git a/modules/DynamoImportTomograms.m b/modules/DynamoImportTomograms.m old mode 100755 new mode 100644 index 64576f9..a6652ea --- a/modules/DynamoImportTomograms.m +++ b/modules/DynamoImportTomograms.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef DynamoImportTomograms < Module methods function obj = DynamoImportTomograms(configuration) diff --git a/modules/DynamoTemplateMatching.m b/modules/DynamoTemplateMatching.m old mode 100755 new mode 100644 index 63c717d..5dbe697 --- a/modules/DynamoTemplateMatching.m +++ b/modules/DynamoTemplateMatching.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef DynamoTemplateMatching < Module methods function obj = DynamoTemplateMatching(configuration) diff --git a/modules/DynamoTiltSeriesAlignment.m b/modules/DynamoTiltSeriesAlignment.m old mode 100755 new mode 100644 index af99dd5..cd34180 --- a/modules/DynamoTiltSeriesAlignment.m +++ b/modules/DynamoTiltSeriesAlignment.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef DynamoTiltSeriesAlignment < Module methods @@ -46,7 +65,7 @@ file = char(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}).tilt_stack_path); obj.dynamic_configuration.tomograms.(field_names{obj.configuration.set_up.j}).config_file_path = config_file_path; if obj.configuration.use_newstack_for_binning == true - [folder, name, extension] = fileparts(file); + %[folder, name, extension] = fileparts(file); system("newstack -in " + file + " -ou binned_stack.st -bin " + obj.configuration.pre_aligned_stack_binning / obj.configuration.ft_bin); file = 'binned_stack.st'; end diff --git a/modules/EMDTemplateGeneration.m b/modules/EMDTemplateGeneration.m old mode 100755 new mode 100644 index 68df7d8..5fa84d5 --- a/modules/EMDTemplateGeneration.m +++ b/modules/EMDTemplateGeneration.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef EMDTemplateGeneration < Module methods function obj = EMDTemplateGeneration(configuration) diff --git a/modules/GCTFCtfphaseflipCTFCorrection.m b/modules/GCTFCtfphaseflipCTFCorrection.m old mode 100755 new mode 100644 index 29bc709..5469207 --- a/modules/GCTFCtfphaseflipCTFCorrection.m +++ b/modules/GCTFCtfphaseflipCTFCorrection.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef GCTFCtfphaseflipCTFCorrection < Module methods function obj = GCTFCtfphaseflipCTFCorrection(configuration) @@ -56,6 +75,11 @@ tilt_stacks = getTiltStacksFromStandardFolder(obj.configuration, true); tilt_stacks = tilt_stacks(contains({tilt_stacks(:).name}, sprintf("%s_%03d", obj.configuration.tomogram_output_prefix, obj.configuration.set_up.j))); end + + if obj.configuration.ctf_estimation_method ~= "gctf" && obj.configuration.ctf_estimation_method ~= "ctffind" + error("ERROR: Unknown CTF-estimation method: " + obj.configuration.ctf_estimation_method); + end + [path, name, extension] = fileparts(tilt_files{1}); tilt_index_angle_mapping = sort(obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(2,:)); for i = 1:length(tilt_stacks) @@ -98,34 +122,44 @@ + slice_folder + string(filesep) + obj.name... + "_" + obj.configuration.slice_suffix + "_", false, obj.log_file_id); return_folder = cd(slice_folder); - disp("INFO: **GCTF ESTIMATION**"); + + disp("INFO: **CTF ESTIMATION**"); + + % NOTE: code block for CTF pre-estimation if isfield(obj.configuration, "nominal_defocus_in_nm") && obj.configuration.nominal_defocus_in_nm ~= 0 % TODO: could be also 2 numbers for lower and upper % limit or factors in different variable names lower_l = round(obj.configuration.nominal_defocus_in_nm / obj.configuration.defocus_limit_factor) * 10^4; upper_l = round(obj.configuration.nominal_defocus_in_nm * obj.configuration.defocus_limit_factor) * 10^4; - else + elseif obj.configuration.ctf_estimation_method == "gctf" if isfield(obj.configuration, "apix") apix = obj.configuration.apix * obj.configuration.ft_bin; else apix = obj.configuration.greatest_apix * obj.configuration.ft_bin; end disp("INFO: Starting Gctf estimation on " + obj.name + "!"); - command = "CUDA_VISIBLE_DEVICES=" + (obj.configuration.set_up.gpu - 1) + " " +obj.configuration.ctf_correction_command... + command = obj.configuration.ctf_correction_command... + + " --gid " + (obj.configuration.set_up.gpu - 1) ... + " --apix " + apix... + " "... + obj.name + "_" + obj.configuration.slice_suffix + "_"; if isfield(obj.configuration, "tilt_index_angle_mapping") && isfield(obj.configuration.tilt_index_angle_mapping, obj.name) - if max(obj.configuration.tilt_index_angle_mapping.(obj.name)(4,:)) < 10 - file = sprintf("%d", obj.configuration.tilt_index_angle_mapping.(obj.name)(4,tilt_index_angle_mapping == 0)); + view_index_max = max(abs(obj.configuration.tilt_index_angle_mapping.(obj.name)(4,:))); + angle_min_abs = min(abs(tilt_index_angle_mapping)); + angle_min = tilt_index_angle_mapping(abs(tilt_index_angle_mapping) == angle_min_abs); + if view_index_max < 10 + file = sprintf("%d", obj.configuration.tilt_index_angle_mapping.(obj.name)(4,tilt_index_angle_mapping == angle_min)); else - file = sprintf("%02d", obj.configuration.tilt_index_angle_mapping.(obj.name)(4,tilt_index_angle_mapping == 0)); + file = sprintf("%02d", obj.configuration.tilt_index_angle_mapping.(obj.name)(4,tilt_index_angle_mapping == angle_min)); end else - if max(obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(4,:)) < 10 - file = sprintf("%d", obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(4,tilt_index_angle_mapping == 0)); + view_index_max = max(abs(obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(4,:))); + angle_min_abs = min(abs(tilt_index_angle_mapping)); + angle_min = tilt_index_angle_mapping(abs(tilt_index_angle_mapping) == angle_min_abs); + if view_index_max < 10 + file = sprintf("%d", obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(4,tilt_index_angle_mapping == angle_min)); else - file = sprintf("%02d", obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(4,tilt_index_angle_mapping == 0)); + file = sprintf("%02d", obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(4,tilt_index_angle_mapping == angle_min)); end end command = command + file + ".mrc"; @@ -157,106 +191,192 @@ obj.dynamic_configuration.global_lower_defocus_average_in_angstrom = obj.dynamic_configuration.global_lower_defocus_average_in_angstrom + lower_l / 2; obj.dynamic_configuration.global_upper_defocus_average_in_angstrom = obj.dynamic_configuration.global_uppper_defocus_average_in_angstrom + upper_l / 2; end - end - disp("INFO: CALCULATED LIMITS: Lower Limit: " + lower_l + " Upper Limit: " + upper_l); - command = "CUDA_VISIBLE_DEVICES=" + (obj.configuration.set_up.gpu - 1) + " " + string(obj.configuration.ctf_correction_command)... - + " --apix " + apix... - + " --defL " + lower_l... - + " --defH " + upper_l... - + " --astm " + obj.configuration.estimated_astigmatism; - if obj.configuration.do_phase_flip == true - disp("INFO: tilt stacks will be CTF-corrected by GCTF."); - command = command + " --do_phase_flip"; - end - if obj.configuration.do_EPA == true - command = command + " --do_EPA"; - end - command = command + " " + obj.name + "*.mrc"; - output = executeCommand(command, false, obj.log_file_id); - - if obj.configuration.do_phase_flip == true - % NOTE: assembling CTF corrected stack - if tilt_stack_extension == "" - tilt_stack_extension = ".st"; + else %if obj.configuration.ctf_estimation_method == "ctffind" + if isfield(obj.configuration, "apix") + apix = obj.configuration.apix * obj.configuration.ft_bin; + else + apix = obj.configuration.greatest_apix * obj.configuration.ft_bin; end - ctf_corrected_stack_destination = obj.output_path... - + string(filesep) + tilt_stack_name... - + "_" + obj.configuration.ctf_corrected_stack_suffix... - + tilt_stack_extension; - tilt_views_ali_ctfc = dir(obj.name + "*_pf.mrc"); - tilt_views_ali_ctfc_list = string([]); - for j=1:length(tilt_views_ali_ctfc) - tilt_views_ali_ctfc_list(j) = tilt_views_ali_ctfc(j).folder + string(filesep) + tilt_views_ali_ctfc(j).name; - end - output = executeCommand("newstack "... - + strjoin(tilt_views_ali_ctfc_list, " ") + " "... - + ctf_corrected_stack_destination, false, obj.log_file_id); + disp("INFO: Starting CTFFIND estimation on " + obj.name + "!"); - % NOTE: linking CTF corrected stack - if contains(tilt_stack_name, "_bin_") - tilt_stack_name_suffix = ""; - splitted_tilt_stack_name = split(tilt_stack_name, "_bin_"); - tilt_stack_ali_bin = str2double(splitted_tilt_stack_name(end)); + if isfield(obj.configuration, "tilt_index_angle_mapping") && isfield(obj.configuration.tilt_index_angle_mapping, obj.name) + view_index_max = max(abs(obj.configuration.tilt_index_angle_mapping.(obj.name)(4,:))); + angle_min_abs = min(abs(tilt_index_angle_mapping)); + angle_min = tilt_index_angle_mapping(abs(tilt_index_angle_mapping) == angle_min_abs); + if view_index_max < 10 + view = sprintf("%d", obj.configuration.tilt_index_angle_mapping.(obj.name)(4,tilt_index_angle_mapping == angle_min)); + else + view = sprintf("%02d", obj.configuration.tilt_index_angle_mapping.(obj.name)(4,tilt_index_angle_mapping == angle_min)); + end else - if obj.configuration.use_aligned_stack == true - tilt_stack_ali_bin = obj.configuration.aligned_stack_binning; + view_index_max = max(abs(obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(4,:))); + angle_min_abs = min(abs(tilt_index_angle_mapping)); + angle_min = tilt_index_angle_mapping(abs(tilt_index_angle_mapping) == angle_min_abs); + if view_index_max < 10 + view = sprintf("%d", obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(4,tilt_index_angle_mapping == angle_min)); else - tilt_stack_ali_bin = 1; + view = sprintf("%02d", obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(4,tilt_index_angle_mapping == angle_min)); end - tilt_stack_name_suffix = "_bin_" + num2str(tilt_stack_ali_bin); end - filename_link_destination = tilt_stack_name + tilt_stack_name_suffix + ".ali"; - - if tilt_stack_ali_bin == 1 - folder_destination = obj.configuration.ctf_corrected_aligned_tilt_stacks_folder; + input_filename = obj.name + "_" + obj.configuration.slice_suffix + "_" + view; + output_filename = input_filename + "_" + obj.configuration.ctffind_output_suffix; + + command = obj.configuration.pipeline_location + string(filesep) + obj.configuration.ctffind_heredoc_path... + + " " + obj.configuration.ctf_correction_command... + + " " + input_filename + ".mrc"... + + " " + output_filename + ".mrc"... + + " " + apix... + + " " + obj.configuration.keV... + + " " + obj.configuration.spherical_aberation... + + " " + obj.configuration.ampContrast... + + " " + obj.configuration.fourier_spectrum_size... + + " " + obj.configuration.resL... + + " " + obj.configuration.resH... + + " " + obj.configuration.defL... + + " " + obj.configuration.defH... + + " " + obj.configuration.ctf_preestim_defS; + + executeCommand(command, false, obj.log_file_id); + + output_fid = fopen(output_filename + ".txt"); + final_values = textscan(output_fid, '%f%f%f%f%f%f%f', 'CommentStyle', '#'); + fclose(output_fid); + + global_defocus_1_in_angstrom = final_values{2}; + global_defocus_2_in_angstrom = final_values{3}; + global_defocus_average_in_angstrom = (global_defocus_1_in_angstrom + global_defocus_2_in_angstrom) / 2; + % TODO: use cosine for defocus interval to be used for + % optimization + lower_l = global_defocus_average_in_angstrom / 2; + upper_l = global_defocus_average_in_angstrom * 1.5; + if ~isfield(obj.dynamic_configuration, "global_lower_defocus_average_in_angstrom") + obj.dynamic_configuration.global_lower_defocus_average_in_angstrom = lower_l; + obj.dynamic_configuration.global_upper_defocus_average_in_angstrom = upper_l; else - folder_destination = obj.configuration.ctf_corrected_binned_aligned_tilt_stacks_folder; + obj.dynamic_configuration.global_lower_defocus_average_in_angstrom = obj.dynamic_configuration.global_lower_defocus_average_in_angstrom + lower_l / 2; + obj.dynamic_configuration.global_upper_defocus_average_in_angstrom = obj.dynamic_configuration.global_uppper_defocus_average_in_angstrom + upper_l / 2; end - - path_destination = obj.configuration.processing_path + filesep + obj.configuration.output_folder + filesep + folder_destination + filesep + obj.name; - link_destination = path_destination + filesep + filename_link_destination; - if exist(path_destination, "dir") - rmdir(path_destination, "s"); - end - mkdir(path_destination); - createSymbolicLink(ctf_corrected_stack_destination, link_destination, obj.log_file_id); + delete(obj.output_path + string(filesep) + obj.configuration.slice_folder + string(filesep) + output_filename + "_avrot.txt"); + delete(obj.output_path + string(filesep) + obj.configuration.slice_folder + string(filesep) + output_filename + ".txt"); + delete(obj.output_path + string(filesep) + obj.configuration.slice_folder + string(filesep) + output_filename + ".mrc"); end + disp("INFO: CALCULATED LIMITS: Lower Limit: " + lower_l + " Upper Limit: " + upper_l); - view_list = dir(slice_folder + string(filesep) + obj.name + "_*_" + "gctf.log"); - if obj.configuration.defocus_file_version <= 2 - j_length = length(view_list); - else - j_length = length(view_list) + 1; - end - for j = 1:j_length - if obj.configuration.defocus_file_version <= 2 - gctf_obj.log_file_id = fopen(view_list(j).folder + string(filesep) + view_list(j).name, "r"); - line_divided_text = textscan(gctf_obj.log_file_id, "%s", "delimiter", "\n"); - final_values = line_divided_text{1}{contains(line_divided_text{1}, "Final Values")}; - final_values_splitted = strsplit(final_values); - local_defocus_1_in_angstrom = str2double(final_values_splitted{1}); - local_defocus_2_in_angstrom = str2double(final_values_splitted{2}); - astigmatism_angle = str2double(final_values_splitted{3}); - local_defocus_1_in_nanometers = local_defocus_1_in_angstrom / 10; - local_defocus_2_in_nanometers = local_defocus_2_in_angstrom / 10; - if local_defocus_1_in_nanometers > local_defocus_2_in_nanometers - local_defocus_in_nanometers_temporary = local_defocus_2_in_nanometers; - local_defocus_2_in_nanometers = local_defocus_1_in_nanometers; - local_defocus_1_in_nanometers = local_defocus_in_nanometers_temporary; - astigmatism_angle = astigmatism_angle - 90; + % NOTE: code block for CTF estimation + if obj.configuration.ctf_estimation_method == "gctf" + command = string(obj.configuration.ctf_correction_command)... + + " --gid " + (obj.configuration.set_up.gpu - 1) ... + + " --apix " + apix... + + " --defL " + lower_l... + + " --defH " + upper_l... + + " --astm " + obj.configuration.estimated_astigmatism; + if obj.configuration.do_phase_flip == true + disp("INFO: tilt stacks will be CTF-corrected by GCTF."); + command = command + " --do_phase_flip"; + end + if obj.configuration.do_EPA == true + command = command + " --do_EPA"; + end + command = command + " " + obj.name + "*.mrc"; + output = executeCommand(command, false, obj.log_file_id); + + if obj.configuration.do_phase_flip == true + % NOTE: assembling CTF corrected stack + if tilt_stack_extension == "" + tilt_stack_extension = ".st"; end - tilt_angle = fgetl(tilt_file_id); - if j == 1 - fwrite(defocus_file_id, sprintf("%s %s %s %s %s %s %s %s\n", num2str(j), num2str(j), num2str(tilt_angle), num2str(tilt_angle), num2str(local_defocus_1_in_nanometers), num2str(local_defocus_2_in_nanometers), num2str(astigmatism_angle), num2str(configuration.defocus_file_version))); + ctf_corrected_stack_destination = obj.output_path... + + string(filesep) + tilt_stack_name... + + "_" + obj.configuration.ctf_corrected_stack_suffix... + + tilt_stack_extension; + tilt_views_ali_ctfc = dir(obj.name + "*_pf.mrc"); + tilt_views_ali_ctfc_list = string([]); + for j=1:length(tilt_views_ali_ctfc) + tilt_views_ali_ctfc_list(j) = tilt_views_ali_ctfc(j).folder + string(filesep) + tilt_views_ali_ctfc(j).name; + end + output = executeCommand("newstack "... + + strjoin(tilt_views_ali_ctfc_list, " ") + " "... + + ctf_corrected_stack_destination, false, obj.log_file_id); + + % NOTE: linking CTF corrected stack + if contains(tilt_stack_name, "_bin_") + tilt_stack_name_suffix = ""; + splitted_tilt_stack_name = split(tilt_stack_name, "_bin_"); + tilt_stack_ali_bin = str2double(splitted_tilt_stack_name(end)); else - fwrite(defocus_file_id, sprintf("%s %s %s %s %s %s %s\n", num2str(j), num2str(j), num2str(tilt_angle), num2str(tilt_angle), num2str(local_defocus_1_in_nanometers), num2str(local_defocus_2_in_nanometers), num2str(astigmatism_angle))); + if obj.configuration.use_aligned_stack == true + tilt_stack_ali_bin = obj.configuration.aligned_stack_binning; + else + tilt_stack_ali_bin = 1; + end + tilt_stack_name_suffix = "_bin_" + num2str(tilt_stack_ali_bin); end - else - if j == 1 - fwrite(defocus_file_id, sprintf("%s 0 0. 0. 0 %s\n", num2str(obj.configuration.defocus_file_version_3_flag), num2str(obj.configuration.defocus_file_version))); + filename_link_destination = tilt_stack_name + tilt_stack_name_suffix + ".ali"; + + if tilt_stack_ali_bin == 1 + folder_destination = obj.configuration.ctf_corrected_aligned_tilt_stacks_folder; else - gctf_obj.log_file_id = fopen(view_list(j-1).folder + string(filesep) + view_list(j-1).name, "r"); + folder_destination = obj.configuration.ctf_corrected_binned_aligned_tilt_stacks_folder; + end + + path_destination = obj.configuration.processing_path + filesep + obj.configuration.output_folder + filesep + folder_destination + filesep + obj.name; + link_destination = path_destination + filesep + filename_link_destination; + + if exist(path_destination, "dir") + rmdir(path_destination, "s"); + end + mkdir(path_destination); + createSymbolicLink(ctf_corrected_stack_destination, link_destination, obj.log_file_id); + end + else %if obj.configuration.ctf_estimation_method == "ctffind" + + command_head = obj.configuration.pipeline_location + string(filesep) + obj.configuration.ctffind_heredoc_path... + + " " + obj.configuration.ctf_correction_command; + + command_tail = apix... + + " " + obj.configuration.keV... + + " " + obj.configuration.spherical_aberation... + + " " + obj.configuration.ampContrast... + + " " + obj.configuration.fourier_spectrum_size... + + " " + obj.configuration.resL... + + " " + obj.configuration.resH... + + " " + lower_l... + + " " + upper_l... + + " " + obj.configuration.ctf_estim_defS; + + view_list = dir(slice_folder + string(filesep) + obj.name + "_*.mrc"); + + %view_indices = obj.configuration.tomograms.(obj.name).tilt_index_angle_mapping(4,:); + %if view_index_max < 10 + % view_indices_str = sprintfc('%d',view_indices); + %else + % view_indices_str = sprintfc('%02d',view_indices); + %end + + for idx=1:length(view_list) + [~, input_filename, ~] = fileparts(view_list(idx).name); + %input_filename = obj.name + "_" + obj.configuration.slice_suffix + "_" + view_index_str; + output_filename = input_filename + "_" + obj.configuration.ctffind_output_suffix; + command = command_head... + + " " + input_filename + ".mrc"... + + " " + output_filename + ".mrc"... + + " " + command_tail; + executeCommand(command, false, obj.log_file_id); + end + end + + % NOTE: code block for writing defocus file + if obj.configuration.ctf_estimation_method == "gctf" + view_list = dir(slice_folder + string(filesep) + obj.name + "_*_" + "gctf.log"); + if obj.configuration.defocus_file_version <= 2 + j_length = length(view_list); + else + j_length = length(view_list) + 1; + end + for j = 1:j_length + if obj.configuration.defocus_file_version <= 2 + gctf_obj.log_file_id = fopen(view_list(j).folder + string(filesep) + view_list(j).name, "r"); line_divided_text = textscan(gctf_obj.log_file_id, "%s", "delimiter", "\n"); final_values = line_divided_text{1}{contains(line_divided_text{1}, "Final Values")}; final_values_splitted = strsplit(final_values); @@ -265,7 +385,6 @@ astigmatism_angle = str2double(final_values_splitted{3}); local_defocus_1_in_nanometers = local_defocus_1_in_angstrom / 10; local_defocus_2_in_nanometers = local_defocus_2_in_angstrom / 10; - if local_defocus_1_in_nanometers > local_defocus_2_in_nanometers local_defocus_in_nanometers_temporary = local_defocus_2_in_nanometers; local_defocus_2_in_nanometers = local_defocus_1_in_nanometers; @@ -273,7 +392,89 @@ astigmatism_angle = astigmatism_angle - 90; end tilt_angle = fgetl(tilt_file_id); - fwrite(defocus_file_id, sprintf("%s %s %s %s %s %s %s\n", num2str(j-1), num2str(j-1), num2str(tilt_angle), num2str(tilt_angle), num2str(local_defocus_1_in_nanometers), num2str(local_defocus_2_in_nanometers), num2str(astigmatism_angle))); + if j == 1 + fwrite(defocus_file_id, sprintf("%s %s %s %s %s %s %s %s\n", num2str(j), num2str(j), num2str(tilt_angle), num2str(tilt_angle), num2str(local_defocus_1_in_nanometers), num2str(local_defocus_2_in_nanometers), num2str(astigmatism_angle), num2str(configuration.defocus_file_version))); + else + fwrite(defocus_file_id, sprintf("%s %s %s %s %s %s %s\n", num2str(j), num2str(j), num2str(tilt_angle), num2str(tilt_angle), num2str(local_defocus_1_in_nanometers), num2str(local_defocus_2_in_nanometers), num2str(astigmatism_angle))); + end + else + if j == 1 + fwrite(defocus_file_id, sprintf("%s 0 0. 0. 0 %s\n", num2str(obj.configuration.defocus_file_version_3_flag), num2str(obj.configuration.defocus_file_version))); + else + gctf_obj.log_file_id = fopen(view_list(j-1).folder + string(filesep) + view_list(j-1).name, "r"); + line_divided_text = textscan(gctf_obj.log_file_id, "%s", "delimiter", "\n"); + final_values = line_divided_text{1}{contains(line_divided_text{1}, "Final Values")}; + final_values_splitted = strsplit(final_values); + local_defocus_1_in_angstrom = str2double(final_values_splitted{1}); + local_defocus_2_in_angstrom = str2double(final_values_splitted{2}); + astigmatism_angle = str2double(final_values_splitted{3}); + local_defocus_1_in_nanometers = local_defocus_1_in_angstrom / 10; + local_defocus_2_in_nanometers = local_defocus_2_in_angstrom / 10; + + if local_defocus_1_in_nanometers > local_defocus_2_in_nanometers + local_defocus_in_nanometers_temporary = local_defocus_2_in_nanometers; + local_defocus_2_in_nanometers = local_defocus_1_in_nanometers; + local_defocus_1_in_nanometers = local_defocus_in_nanometers_temporary; + astigmatism_angle = astigmatism_angle - 90; + end + tilt_angle = fgetl(tilt_file_id); + fwrite(defocus_file_id, sprintf("%s %s %s %s %s %s %s\n", num2str(j-1), num2str(j-1), num2str(tilt_angle), num2str(tilt_angle), num2str(local_defocus_1_in_nanometers), num2str(local_defocus_2_in_nanometers), num2str(astigmatism_angle))); + end + end + end + else + defocus_file_list = dir(slice_folder + string(filesep) + obj.name + "*" + obj.configuration.ctffind_output_suffix + ".txt"); + j_length = length(defocus_file_list); + if obj.configuration.defocus_file_version <= 2 + j_start = 1; + else + j_start = 0; + end + for j = j_start:j_length + if obj.configuration.defocus_file_version <= 2 + output_file_id = fopen(defocus_file_list(j).folder + string(filesep) + defocus_file_list(j).name, "r"); + final_values = textscan(output_file_id, '%f%f%f%f%f%f%f', 'CommentStyle', '#'); + fclose(output_file_id); + + local_defocus_1_in_angstrom = final_values{2}; + local_defocus_2_in_angstrom = final_values{3}; + astigmatism_angle = final_values{4}; + local_defocus_1_in_nanometers = local_defocus_1_in_angstrom / 10; + local_defocus_2_in_nanometers = local_defocus_2_in_angstrom / 10; + if local_defocus_1_in_nanometers > local_defocus_2_in_nanometers + local_defocus_in_nanometers_temporary = local_defocus_2_in_nanometers; + local_defocus_2_in_nanometers = local_defocus_1_in_nanometers; + local_defocus_1_in_nanometers = local_defocus_in_nanometers_temporary; + astigmatism_angle = astigmatism_angle - 90; + end + tilt_angle = fgetl(tilt_file_id); + if j == 1 + fwrite(defocus_file_id, sprintf("%s %s %s %s %s %s %s %s\n", num2str(j), num2str(j), num2str(tilt_angle), num2str(tilt_angle), num2str(local_defocus_1_in_nanometers), num2str(local_defocus_2_in_nanometers), num2str(astigmatism_angle), num2str(configuration.defocus_file_version))); + else + fwrite(defocus_file_id, sprintf("%s %s %s %s %s %s %s\n", num2str(j), num2str(j), num2str(tilt_angle), num2str(tilt_angle), num2str(local_defocus_1_in_nanometers), num2str(local_defocus_2_in_nanometers), num2str(astigmatism_angle))); + end + else + if j == 0 + fwrite(defocus_file_id, sprintf("%s 0 0. 0. 0 %s\n", num2str(obj.configuration.defocus_file_version_3_flag), num2str(obj.configuration.defocus_file_version))); + else + output_file_id = fopen(defocus_file_list(j).folder + string(filesep) + defocus_file_list(j).name, "r"); + final_values = textscan(output_file_id, '%f%f%f%f%f%f%f', 'CommentStyle', '#'); + fclose(output_file_id); + local_defocus_1_in_angstrom = final_values{2}; + local_defocus_2_in_angstrom = final_values{3}; + astigmatism_angle = final_values{4}; + local_defocus_1_in_nanometers = local_defocus_1_in_angstrom / 10; + local_defocus_2_in_nanometers = local_defocus_2_in_angstrom / 10; + + if local_defocus_1_in_nanometers > local_defocus_2_in_nanometers + local_defocus_in_nanometers_temporary = local_defocus_2_in_nanometers; + local_defocus_2_in_nanometers = local_defocus_1_in_nanometers; + local_defocus_1_in_nanometers = local_defocus_in_nanometers_temporary; + astigmatism_angle = astigmatism_angle - 90; + end + tilt_angle = fgetl(tilt_file_id); + fwrite(defocus_file_id, sprintf("%s %s %s %s %s %s %s\n", num2str(j), num2str(j), num2str(tilt_angle), num2str(tilt_angle), num2str(local_defocus_1_in_nanometers), num2str(local_defocus_2_in_nanometers), num2str(astigmatism_angle))); + end end end end @@ -281,7 +482,6 @@ fclose(tilt_file_id); cd(return_folder); end - if obj.configuration.run_ctf_phase_flip == true disp("INFO: tilt stacks will be CTF-corrected by Ctfphaseflip."); % NOTE: run Ctfphaseflip CTF-correction always on aligned stack @@ -322,28 +522,7 @@ % and use XF transform file while correcting CTF % TODO: find better way to make checks % (e.g. link xf files to separate folder) - xf_files = getFilesFromLastModuleRun(obj.configuration,"AreTomo","xf","last"); - if ~isempty(xf_files) - xf_files = xf_files{1}; - else - xf_files = getFilesFromLastModuleRun(obj.configuration,"AreTomo","aln","last"); - if isempty(xf_files) - xf_files = getFilePathsFromLastBatchruntomoRun(obj.configuration, "xf"); - xf_files = xf_files{1}; - else - fid_in = fopen(xf_files{1}); - lines_in_cells = textscan(fid_in, "%s","Delimiter","\n"); - fclose(fid_in); - fid_out = fopen(obj.output_path + filesep + obj.name + ".xf", "w+"); - for j = 4:length(lines_in_cells{1}) - numbers_in_line = textscan(lines_in_cells{1}{j}, "%f %f %f %f %f %f %f %f %f %f"); - rotation_matrix = rotz(numbers_in_line{2}); - fprintf(fid_out, "%f %f %f %f %f %f\n", rotation_matrix(1,1), rotation_matrix(1,2), rotation_matrix(2,1), rotation_matrix(2,2), numbers_in_line{4}, numbers_in_line{5}); - end - fclose(fid_out); - xf_files = obj.output_path + filesep + obj.name + ".xf"; - end - end + xf_files = getXfOrAlnFilePaths(obj.configuration, obj.output_path, obj.name); xf_file_destination = destination_folder + string(filesep) + obj.name + ".xf"; createSymbolicLink(xf_files, xf_file_destination, obj.log_file_id); diff --git a/modules/GainCorrection.m b/modules/GainCorrection.m old mode 100755 new mode 100644 index f5908fa..bfc8e25 --- a/modules/GainCorrection.m +++ b/modules/GainCorrection.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % NOTE:TODO: relion_estimate_gain classdef GainCorrection < Module diff --git a/modules/GenerateParticles.m b/modules/GenerateParticles.m new file mode 100644 index 0000000..b1b368c --- /dev/null +++ b/modules/GenerateParticles.m @@ -0,0 +1,75 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +classdef GenerateParticles < Module + methods + function obj = GenerateParticles(configuration) + obj@Module(configuration); + end + + function obj = process(obj) + return_path = cd(obj.configuration.output_path); + + paths = getFilesFromLastModuleRun(obj.configuration, "DynamoAlignmentProject", "", "prelast"); + + if isfield(obj.configuration, "particles_table_path") && obj.configuration.particles_table_path ~= "" + tab_all_path = dir(obj.configuration.particles_table_path); + previous_binning = -1; + elseif ~isempty(paths) + alignment_folder = dir(paths{1} + filesep + "alignment_project*"); + alignment_folder_splitted = strsplit(alignment_folder.name, "_"); + previous_binning = str2double(alignment_folder_splitted{end}); + iteration_path = dir(paths{1} + filesep + "*" + filesep + "*" + filesep + "results" + filesep + "ite_*"); + tab_all_path = dir(string(iteration_path(end-1).folder) + filesep + iteration_path(end-1).name + filesep + "averages" + filesep + "*.tbl"); + else + tab_all_path = dir(obj.configuration.processing_path + string(filesep) + obj.configuration.output_folder + string(filesep) + obj.configuration.particles_table_folder + string(filesep) + "*.tbl"); + tab_all_path_name = strsplit(tab_all_path.name, "_"); + previous_binning = str2double(tab_all_path_name{5}); + end + particles_table = tab_all_path(end).folder + string(filesep) + tab_all_path(end).name; + + if isfield(obj.configuration, "particles_binning") && obj.configuration.particles_binning ~= -1 + particles_binning = obj.configuration.particles_binning; + elseif previous_binning ~= -1 + particles_binning = previous_binning; + else + error("ERROR: Binning level was not auto-identified and was not set by the user! Please, use particles_binning parameter.") + end + + rec_resampled = getMask(obj.configuration); + + if ~isempty(rec_resampled) && obj.configuration.box_size >= 1 && obj.configuration.box_size <= 10 + box_size = round(size(rec_resampled, 1) * obj.configuration.box_size); + else + box_size = obj.configuration.box_size; + end + if mod(box_size, 2) == 1 + disp("INFO: resulting box size is odd, adding 1 to make it even!") + box_size = box_size + 1; + end + + if obj.configuration.use_SUSAN == true + generateParticles(obj.configuration, particles_table, particles_binning, box_size, true, "susan"); + else + generateParticles(obj.configuration, particles_table, particles_binning, box_size, true, "dynamo"); + end + cd(return_path); + end + end +end \ No newline at end of file diff --git a/modules/GridEdgeEraser.m b/modules/GridEdgeEraser.m index 89bf528..d0d0a3d 100644 --- a/modules/GridEdgeEraser.m +++ b/modules/GridEdgeEraser.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef GridEdgeEraser < Module methods function obj = GridEdgeEraser(configuration) diff --git a/modules/IsoNet.m b/modules/IsoNet.m new file mode 100644 index 0000000..199ef5c --- /dev/null +++ b/modules/IsoNet.m @@ -0,0 +1,360 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% NOTE: https://github.com/IsoNet-cryoET/IsoNet + +classdef IsoNet < Module + methods + function obj = IsoNet(configuration) + obj@Module(configuration); + end + + function obj = process(obj) + + return_path = cd(obj.output_path); + + steps_to_execute_fields = fieldnames(obj.configuration.steps_to_execute); + + if isempty(steps_to_execute_fields) + error("ERROR: No IsoNet steps_to_execute were found in the JSON file!"); + end + + % NOTE: add 'success' files to be able to re-run substeps + + for subjob_idx=1:length(steps_to_execute_fields) + disp("INFO: IsoNet substep " + string(subjob_idx) + ":" + string(steps_to_execute_fields{subjob_idx})); + step_params = mergeConfigurations(obj.configuration.steps_to_execute_defaults.(steps_to_execute_fields{subjob_idx}), obj.configuration.steps_to_execute.(steps_to_execute_fields{subjob_idx}), "IsoNet", "dynamic"); + obj.(steps_to_execute_fields{subjob_idx})(steps_to_execute_fields{subjob_idx}, step_params); + disp("INFO: Execution for IsoNet substep " + string(subjob_idx) +" (" + string(steps_to_execute_fields{subjob_idx}) + ") has finished!"); + end + + cd(return_path); + end + + function obj = prepare_star(obj, step_name, step_params) + + if step_params.use_ctf_corrected_tomograms == false + tomograms = getBinnedTomogramsFromStandardFolder(obj.configuration, true); + if isempty(tomograms) + error("ERROR: no non-ctf corrected tomograms were found!"); + end + else + tomograms = getCtfCorrectedBinnedTomogramsFromStandardFolder(obj.configuration, true); + if isempty(tomograms) + error("ERROR: no ctf corrected tomograms were found!"); + end + end + + if step_params.tomograms_binning == -1 + binnings = sort(obj.configuration.binnings, "descend"); + tomograms_all = tomograms; + for bin_idx=1:length(binnings) + tomograms = tomograms_all(contains({tomograms_all.name}, "bin_" + num2str(binnings(bin_idx)))); + if ~isempty(tomograms) + binning = binnings(bin_idx); + break + end + end + elseif step_params.tomograms_binning > 1 + binning = step_params.tomograms_binning; + tomograms = tomograms(contains({tomograms.name}, "bin_" + binning)); + else + error("ERROR: only binned tomograms usage is possible in IsoNet module..."); + end + + if isempty(tomograms) + error("ERROR: no tomograms with the specified binning of were found!"); + end + + if ~isempty(obj.configuration.tomograms_to_use) + tomograms_to_star_str = string(arrayfun(@(a)num2str(a, '%03.f'),obj.configuration.tomograms_to_use,'uni',0)); + tomograms = tomograms(contains(string({tomograms(:).name}), "tomogram_"+tomograms_to_star_str)); + + if isempty(tomograms) + error("ERROR: no tomograms with the specified indices were found!"); + end + end + + % NOTE: add possibility to use external tomograms + tomograms_path = obj.output_path + string(filesep) + step_params.folder_name; + mkdir(tomograms_path); + for tomo_idx=1:length(tomograms) + tomogram_source = tomograms(tomo_idx).folder + string(filesep) + tomograms(tomo_idx).name; + link_destination = tomograms_path + string(filesep) + tomograms(tomo_idx).name; + createSymbolicLink(tomogram_source, link_destination, obj.log_file_id); + end + + use_params = obj.getRequestedOnlyParametersStructure(step_params, {'output_star', 'number_subtomos'}); + % NOTE: Add eer_upsampling parsing for EER data case!!! + use_params.pixel_size = obj.configuration.apix * obj.configuration.ft_bin * binning; + + params_string = obj.getParamsString(use_params); + params_string = step_name + " " + tomograms_path + params_string; + command_output = obj.executeIsoNetCommand(params_string); + + if step_params.add_defocus_to_star == true + disp("INFO: adding defocus info to STAR file..."); + output_star_def = obj.editDefocusValueInStarFile(step_params.output_star); + movefile(step_params.output_star, step_params.output_star + "~"); + movefile(output_star_def, step_params.output_star); + % rewrite original star file with defocus included!!! + else + disp("INFO: adding defocus info to STAR file was disabled by user!"); + end + end + + function new_star_path = editDefocusValueInStarFile(obj, star_path) + + % NOTE: get defocus info from .defocus files + defocus_files = getDefocusFiles(obj.configuration, '.defocus'); + + star_fid = fopen(star_path, 'r'); + + [star_path, star_name, star_ext] = fileparts(star_path); + if star_path ~= "" + new_star_path = star_path + string(filesep) + star_name + "_def" + star_ext; + else + new_star_path = star_name + "_def" + star_ext; + end + new_star_fid = fopen(new_star_path, 'w'); + + % NOTE: loop over lines before _rln fields and write them + while ~feof(star_fid) + fl = fgetl(star_fid); + if isempty(regexp(fl,'_rln', 'once')) + nl = fl; fprintf(new_star_fid, '%s\n', nl); + else + break + end + end + + % NOTE: loop over lines of _rln fields and write them + + while ~feof(star_fid) + if ~isempty(regexp(fl,'_rln', 'once')) + nl = fl; fprintf(new_star_fid, '%s\n', nl); + else + break + end + fl = fgetl(star_fid); + end + + % NOTE: read tomograms data, add defoci and write them + while ~feof(star_fid) + if ~isempty(regexp(fl,'tomogram_', 'once')) + flsp = split(strtrim(fl)); + + % NOTE: 2nd column is tomogram filepath + [~, tomo_name, ~] = fileparts(flsp(2)); + + % NOTE: 2nd part of tomogram filename is tomogram number + tomo_name_split = split(tomo_name, '_'); + tomo_num = str2double(tomo_name_split(2)); + + defocus_file = defocus_files(tomo_num); + defocus_file_path = defocus_file{1}.folder + string(filesep) + defocus_file{1}.name; + defocus_ave = obj.getAverageDefocusFromDefocusFile(defocus_file_path); + + % NOTE: 4th column is tomogram global defocus + fprintf(new_star_fid, '%s\t%s\t%s\t%.2f\t%s\t%s\n',flsp{1},flsp{2},flsp{3},defocus_ave,flsp{5},flsp{6}); + else + break + end + fl = fgetl(star_fid); + end + + fclose(star_fid); + fclose(new_star_fid); + end + + function defocus_ave = getAverageDefocusFromDefocusFile(obj, defocus_file_path) + + defocus_fid = fopen(defocus_file_path, 'rt'); + txt = textscan(defocus_fid , '%s', 'Delimiter', '\n'); + txt = txt{1}; + + % NOTE: use value bigger than upper bond as initial minima + angle_abs_min = 90; + for idx=1:length(txt) + txt_data = split(strtrim(txt{idx})); + % NOTE: <7 values is header of .defocus file v3 + if length(txt_data) < 7 + continue; + end + angle_abs = abs(str2double(txt_data{3})); + if angle_abs < angle_abs_min + angle_abs_min = angle_abs; + defocus_ave_min = (str2double(txt_data{5}) + str2double(txt_data{6}))/2; + end + end + fclose(defocus_fid); + + defocus_ave = defocus_ave_min; + end + + function obj = deconv(obj, step_name, step_params) + + if ~isfile(step_params.star_file) + error('ERROR: the requested star_file was not found!'); + end + + use_params_cell = {'deconv_folder',... + 'snrfalloff', 'deconvstrength', 'highpassnyquist',... + 'chunk_size', 'overlap_rate'}; + use_params = obj.getRequestedOnlyParametersStructure(step_params, use_params_cell); + use_params.deconv_folder = obj.output_path + string(filesep) + use_params.deconv_folder; + if step_params.ncpu == -1 + use_params.ncpu = getCpuPoolSize(1); + else + use_params.ncpu = getCpuPoolSize(1, step_params.ncpu); + end + + params_string = obj.getParamsString(use_params); + params_string = step_name + " " + step_params.star_file + params_string; + command_output = obj.executeIsoNetCommand(params_string); + end + + function obj = make_mask(obj, step_name, step_params) + + if ~isfile(step_params.star_file) + error('ERROR: the requested star_file was not found!'); + end + + use_params_cell = {'mask_folder',... + 'patch_size', 'mask_boundary',... + 'density_percentage', 'std_percentage',... + 'z_crop', 'use_deconv_tomo'}; + use_params = obj.getRequestedOnlyParametersStructure(step_params, use_params_cell); + use_params.mask_folder = obj.output_path + string(filesep) + use_params.mask_folder; + + params_string = obj.getParamsString(use_params); + params_string = step_name + " " + step_params.star_file + params_string; + command_output = obj.executeIsoNetCommand(params_string); + end + + function obj = extract(obj, step_name, step_params) + + if ~isfile(step_params.star_file) + error('ERROR: the requested star_file was not found!'); + end + + use_params_cell = {'subtomo_folder', 'subtomo_star'... + 'cube_size', 'crop_size',... + 'use_deconv_tomo'}; + use_params = obj.getRequestedOnlyParametersStructure(step_params, use_params_cell); + use_params.subtomo_folder = obj.output_path + string(filesep) + use_params.subtomo_folder; + + params_string = obj.getParamsString(use_params); + params_string = step_name + " " + step_params.star_file + params_string; + command_output = obj.executeIsoNetCommand(params_string); + end + + function obj = refine(obj, step_name, step_params) + + if ~isfile(step_params.subtomo_star) + error('ERROR: the requested subtomo_star was not found!'); + end + + if obj.configuration.gpu > 0 + step_params.gpuID = obj.configuration.gpu - 1; + else + error("ERROR: Gpus are needed to train IsoNet!"); + end + + use_params_cell = {'iterations',... + 'data_dir','result_dir',... + 'pretrained_model', 'continue_from',... + 'epochs', 'batch_size', 'steps_per_epoch',... + 'noise_level', 'noise_start_iter', 'noise_mode', 'noise_dir',... + 'learning_rate', 'drop_out', 'convs_per_depth',... + 'kernel', 'unet_depth', 'filter_base',... + 'batch_normalization', 'normalize_percentile',... + 'gpuID'}; + + use_params = obj.getRequestedOnlyParametersStructure(step_params, use_params_cell); + use_params.result_dir = obj.output_path + string(filesep) + use_params.result_dir; + + if step_params.preprocessing_ncpus == -1 + use_params.preprocessing_ncpus = getCpuPoolSize(1); + else + use_params.preprocessing_ncpus = getCpuPoolSize(1, step_params.preprocessing_ncpus); + end + + params_string = obj.getParamsString(use_params); + params_string = step_name + " " + step_params.subtomo_star + params_string; + command_output = obj.executeIsoNetCommand(params_string); + end + + function obj = predict(obj, step_name, step_params) + + if ~isfile(step_params.star_file) + error('ERROR: the requested star_file was not found!'); + end + + if obj.configuration.gpu > 0 + step_params.gpuID = obj.configuration.gpu - 1; + else + error("ERROR: Gpus are needed to train IsoNet!"); + end + + use_params_cell = {'model', 'output_dir'... + 'cube_size', 'crop_size',... + 'batch_size', 'normalize_percentile',... + 'gpuID'}; + use_params = obj.getRequestedOnlyParametersStructure(step_params, use_params_cell); + use_params.output_dir = obj.output_path + string(filesep) + use_params.output_dir; + + params_string = obj.getParamsString(use_params); + params_string = step_name + " " + step_params.star_file + params_string; + command_output = obj.executeIsoNetCommand(params_string); + end + + function parameters_req = getRequestedOnlyParametersStructure(obj, parameters_all, parameters_req_names) + parameters_req = struct(); + for idx=1:length(parameters_req_names) + param_value = parameters_all.(parameters_req_names{idx}); + if (isstring(param_value) && param_value ~= "")... + || (isnumeric(param_value) && isscalar(param_value) && param_value ~= -1) + parameters_req.(parameters_req_names{idx}) = param_value; + elseif isnumeric(param_value) && ~isscalar(param_value) && ~isempty(param_value) + parameters_req.(parameters_req_names{idx}) = strjoin(string(param_value), ","); + end + end + end + + function params_string = getParamsString(obj, params) + params_fields = fieldnames(params); + params_string = ""; + for idx=1:length(params_fields) + params_string = params_string + " --" + params_fields{idx} + " " + params.(params_fields{idx}); + end + end + + function command_output = executeIsoNetCommand(obj, params_string) + python_run_script_snippet = "PYTHONPATH=" + fullfile(obj.configuration.repository_path, '..'); + if obj.configuration.use_conda == true + python_run_script_snippet = python_run_script_snippet + " LD_LIBRARY_PATH=" + obj.configuration.conda_path + filesep + "lib:$LD_LIBRARY_PATH conda run -n " + obj.configuration.isonet_env; + end + python_run_script_snippet = python_run_script_snippet + " python " + obj.configuration.repository_path + filesep + "bin/isonet.py"; + command_output = executeCommand(python_run_script_snippet + " " + params_string, false, obj.log_file_id); + end + + end +end + diff --git a/modules/MetaData.m b/modules/MetaData.m old mode 100755 new mode 100644 index f8e3f1b..1c218ef --- a/modules/MetaData.m +++ b/modules/MetaData.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef MetaData < Module methods function obj = MetaData(configuration) diff --git a/modules/Module.m b/modules/Module.m old mode 100755 new mode 100644 index 8ed7a9c..ab8e58c --- a/modules/Module.m +++ b/modules/Module.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef (Abstract) Module properties configuration struct; diff --git a/modules/MotionCor2.m b/modules/MotionCor2.m old mode 100755 new mode 100644 index 3cbc520..cb6fa48 --- a/modules/MotionCor2.m +++ b/modules/MotionCor2.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef MotionCor2 < Module methods function obj = MotionCor2(configuration) @@ -26,8 +45,10 @@ mrc_list = obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}).raw_files; - if obj.configuration.method == "MotionCor2" + if obj.configuration.method == "MotionCor2" [motion_corrected_files, symbolic_link_standard_folder] = obj.correctWithMotionCor2(mrc_list); + elseif obj.configuration.method == "SumOnly" + [motion_corrected_files, symbolic_link_standard_folder] = obj.summarizeOnly(mrc_list); else [motion_corrected_files, symbolic_link_standard_folder] = obj.correctWithAlignFrames(mrc_list); end @@ -172,10 +193,17 @@ [folder, name, extension] = fileparts(obj.configuration.gain); name_rep = strrep(name, " ", "\ "); gain_path = folder + string(filesep) + name_rep + extension; - if ~fileExists(output_folder + string(filesep) + name + ".mrc") && extension == ".dm4" - gain_path = output_folder + string(filesep) + name_rep + ".mrc"; - executeCommand("dm2mrc -u " + folder + string(filesep) + name_rep + extension + " " + gain_path); - elseif fileExists(output_folder + string(filesep) + name + ".mrc") && extension == ".dm4" + if ~fileExists(output_folder + string(filesep) + name + ".mrc") + if extension == ".dm4" + gain_path_new = output_folder + string(filesep) + name_rep + ".mrc"; + executeCommand("dm2mrc -u " + gain_path + " " + gain_path_new); + gain_path = gain_path_new; + elseif extension == ".gain" + gain_path_new = output_folder + string(filesep) + name_rep + ".mrc"; + executeCommand("newstack -in " + gain_path + " -ou " + gain_path_new); + gain_path = gain_path_new; + end + elseif extension == ".dm4" || extension == ".gain" gain_path = output_folder + string(filesep) + name_rep + ".mrc"; end @@ -397,6 +425,47 @@ end end + function [motion_corrected_files, symbolic_link_standard_folder] = summarizeOnly(obj, mrc_list) + disp("INFO: Method - summarize movies without correction"); + disp("INFO: Getting ready to process..."); + disp("INFO: Processing micrographs in " + obj.configuration.output_folder); + + % TODO: support for frame integration files + field_names = fieldnames(obj.configuration.tomograms); + + mkdir(obj.configuration.processing_path + string(filesep)... + + obj.configuration.output_folder + string(filesep)... + + obj.configuration.motion_corrected_files_folder + string(filesep) + field_names{obj.configuration.set_up.j}); + + output_folder = obj.output_path; + configuration = obj.configuration; + log_file_id = -1; + + parfor i = 1:length(mrc_list) + disp("INFO: Processing " + mrc_list(i) + "..."); + + % TODO: is the output_postfix needed? makes + % createSymbolicLinkInStandardFolder more complicated + %mrc_output = output_folder + string(filesep) + name + "_" + configuration.output_postfix + ".mrc"; + [~, name, ~] = fileparts(mrc_list{i}); + mrc_output = output_folder + string(filesep) + name + ".mrc"; + + input_movie = dread(mrc_list(i)); + output_frame = sum(input_movie, 3); + dwrite(output_frame, mrc_output); + + [output_symbolic_link_standard_folder, symbolic_link_standard_folder(i)] = createSymbolicLinkInStandardFolder(configuration, mrc_output, "motion_corrected_files_folder", log_file_id); + motion_corrected_files{i} = mrc_output; + end + + if obj.configuration.ft_bin ~= 1 + ft_bin = obj.configuration.ft_bin; + parfor i = 1:length(motion_corrected_files) + system("newstack -in " + motion_corrected_files{i} + " -ou " + motion_corrected_files{i} + " -bin " + ft_bin); + end + end + end + function [motion_corrected_files, symbolic_link_standard_folder] = correctWithAlignFrames(obj, mrc_list) error("ERROR: alignframes fall back not implemented yet"); % TODO: Look up default gain value for motioncorr2 diff --git a/modules/PolishParticlesAndEstimateResolution.m b/modules/PolishParticlesAndEstimateResolution.m index b079768..15b9174 100644 --- a/modules/PolishParticlesAndEstimateResolution.m +++ b/modules/PolishParticlesAndEstimateResolution.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef PolishParticlesAndEstimateResolution < Module methods function obj = PolishParticlesAndEstimateResolution(configuration) diff --git a/modules/Reconstruct.m b/modules/Reconstruct.m old mode 100755 new mode 100644 index 198730d..a9e72c7 --- a/modules/Reconstruct.m +++ b/modules/Reconstruct.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef Reconstruct < Module methods function obj = Reconstruct(configuration) @@ -54,27 +73,28 @@ binned_aligned_tilt_stacks = binned_aligned_tilt_stacks(~contains({binned_aligned_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); end - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") - dose_weighted_tilt_stacks = getCtfCorrectedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); - end - - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") - dose_weighted_sum_tilt_stacks = getCtfCorrectedDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); - end - - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") - binned_dose_weighted_tilt_stacks = getCtfCorrectedBinnedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); - if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) - binned_dose_weighted_tilt_stacks = binned_dose_weighted_tilt_stacks(~contains({binned_dose_weighted_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); - end - end - - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") - binned_dose_weighted_sum_tilt_stacks = getCtfCorrectedBinnedDoseWeightedSumTiltStacksFromStandardFolde(obj.configuration, true); - if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) - binned_dose_weighted_sum_tilt_stacks = binned_dose_weighted_sum_tilt_stacks(~contains({binned_dose_weighted_sum_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); - end - end + % NOTE: switched off until refactoring +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") +% dose_weighted_tilt_stacks = getCtfCorrectedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); +% end +% +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") +% dose_weighted_sum_tilt_stacks = getCtfCorrectedDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); +% end + +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") +% binned_dose_weighted_tilt_stacks = getCtfCorrectedBinnedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); +% if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) +% binned_dose_weighted_tilt_stacks = binned_dose_weighted_tilt_stacks(~contains({binned_dose_weighted_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); +% end +% end +% +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") +% binned_dose_weighted_sum_tilt_stacks = getCtfCorrectedBinnedDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); +% if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) +% binned_dose_weighted_sum_tilt_stacks = binned_dose_weighted_sum_tilt_stacks(~contains({binned_dose_weighted_sum_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); +% end +% end if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_even_files") even_tilt_stacks = getCtfCorrectedEvenTiltStacksFromStandardFolder(obj.configuration, true); @@ -112,19 +132,20 @@ dose_weighted_sum_tilt_stacks = getDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); end - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") - binned_dose_weighted_tilt_stacks = getBinnedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); - if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) - binned_dose_weighted_tilt_stacks = binned_dose_weighted_tilt_stacks(~contains({binned_dose_weighted_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); - end - end - - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") - binned_dose_weighted_sum_tilt_stacks = getBinnedDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); - if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) - binned_dose_weighted_sum_tilt_stacks = binned_dose_weighted_sum_tilt_stacks(~contains({binned_dose_weighted_sum_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); - end - end + % NOTE: switched off until refactoring +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") +% binned_dose_weighted_tilt_stacks = getBinnedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); +% if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) +% binned_dose_weighted_tilt_stacks = binned_dose_weighted_tilt_stacks(~contains({binned_dose_weighted_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); +% end +% end +% +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") +% binned_dose_weighted_sum_tilt_stacks = getBinnedDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); +% if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) +% binned_dose_weighted_sum_tilt_stacks = binned_dose_weighted_sum_tilt_stacks(~contains({binned_dose_weighted_sum_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); +% end +% end if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_even_files") even_tilt_stacks = getEvenTiltStacksFromStandardFolder(obj.configuration, true); @@ -159,13 +180,14 @@ odd_tilt_stacks = getCtfCorrectedOddTiltStacksFromStandardFolder(obj.configuration, true); end - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") - dose_weighted_tilt_stacks = getCtfCorrectedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); - end - - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") - dose_weighted_sum_tilt_stacks = getCtfCorrectedDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); - end + % NOTE: switched off until refactoring +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") +% dose_weighted_tilt_stacks = getCtfCorrectedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); +% end +% +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") +% dose_weighted_sum_tilt_stacks = getCtfCorrectedDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); +% end else aligned_tilt_stack = getAlignedTiltStacksFromStandardFolder(obj.configuration, true); @@ -177,13 +199,14 @@ odd_tilt_stacks = getOddTiltStacksFromStandardFolder(obj.configuration, true); end - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") - dose_weighted_tilt_stacks = getDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); - end - - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") - dose_weighted_sum_tilt_stacks = getDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); - end + % NOTE: switched off until refactoring +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") +% dose_weighted_tilt_stacks = getDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); +% end +% +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") +% dose_weighted_sum_tilt_stacks = getDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); +% end end elseif obj.configuration.reconstruct == "binned" if obj.configuration.use_ctf_corrected_stack == true @@ -206,19 +229,20 @@ end end - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") - binned_dose_weighted_tilt_stacks = getCtfCorrectedBinnedAlignedDoseWeightedTiltStacksFromStandardF(obj.configuration, true); - if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) - binned_dose_weighted_tilt_stacks = binned_dose_weighted_tilt_stacks(~contains({binned_dose_weighted_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); - end - end - - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") - binned_dose_weighted_sum_tilt_stacks = getCtfCorrectedBinnedAlignedDoseWeightedSumTiltStacksFromStanda(obj.configuration, true); - if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) - binned_dose_weighted_sum_tilt_stacks = binned_dose_weighted_sum_tilt_stacks(~contains({binned_dose_weighted_sum_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); - end - end + % NOTE: switched off until refactoring +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") +% binned_dose_weighted_tilt_stacks = getCtfCorrectedBinnedAlignedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); +% if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) +% binned_dose_weighted_tilt_stacks = binned_dose_weighted_tilt_stacks(~contains({binned_dose_weighted_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); +% end +% end +% +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") +% binned_dose_weighted_sum_tilt_stacks = getCtfCorrectedBinnedAlignedDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); +% if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) +% binned_dose_weighted_sum_tilt_stacks = binned_dose_weighted_sum_tilt_stacks(~contains({binned_dose_weighted_sum_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); +% end +% end else binned_aligned_tilt_stacks = getBinnedAlignedTiltStacksFromStandardFolder(obj.configuration, true); if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) @@ -239,19 +263,20 @@ end end - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") - binned_dose_weighted_tilt_stacks = getBinnedAlignedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); - if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) - binned_dose_weighted_tilt_stacks = binned_dose_weighted_tilt_stacks(~contains({binned_dose_weighted_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); - end - end - - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") - binned_dose_weighted_sum_tilt_stacks = getBinnedAlignedDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); - if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) - binned_dose_weighted_sum_tilt_stacks = binned_dose_weighted_sum_tilt_stacks(~contains({binned_dose_weighted_sum_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); - end - end + % NOTE: switched off until refactoring +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") +% binned_dose_weighted_tilt_stacks = getBinnedAlignedDoseWeightedTiltStacksFromStandardFolder(obj.configuration, true); +% if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) +% binned_dose_weighted_tilt_stacks = binned_dose_weighted_tilt_stacks(~contains({binned_dose_weighted_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); +% end +% end +% +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") +% binned_dose_weighted_sum_tilt_stacks = getBinnedAlignedDoseWeightedSumTiltStacksFromStandardFolder(obj.configuration, true); +% if ~any(obj.configuration.binnings == obj.configuration.aligned_stack_binning) +% binned_dose_weighted_sum_tilt_stacks = binned_dose_weighted_sum_tilt_stacks(~contains({binned_dose_weighted_sum_tilt_stacks.name}, "bin_" + obj.configuration.aligned_stack_binning)); +% end +% end end else error("ERROR: tomogram type unknown!"); @@ -473,7 +498,7 @@ if isfield(obj.configuration, "exclude_lists") && isfield(obj.configuration.exclude_lists, name) command = command + " -EXCLUDELIST2 " + strjoin(strsplit(num2str(obj.configuration.exclude_lists.(name))), ","); - else + elseif ~isempty(getFilePathsFromLastBatchruntomoRun(obj.configuration, "fid")) fid_files = getFilePathsFromLastBatchruntomoRun(obj.configuration, "fid"); executeCommand("model2point " + fid_files{1} + " " + obj.output_path + filesep + "fiducial.point", false, obj.log_file_id); fiducials = dlmread(obj.output_path + filesep + "fiducial.point"); @@ -500,7 +525,50 @@ if contains(name, obj.configuration.ctf_corrected_stack_suffix) || obj.configuration.use_ctf_corrected_stack == true createSymbolicLinkInStandardFolder(obj.configuration, exact_filtered_rotated_tomogram_destination, "exact_filtered_ctf_corrected_binned_tomograms_folder", obj.log_file_id); else - createSymbolicLinkInStandardFolder(obj.configuration, exact_filtered_rotated_tomogram_destination, "exact_filtered_binned_tomograms_folder", obj.log_file_id); + createSymbolicLinkInStandardFolder(obj.configuration, exact_filtered_rotated_tomogram_destination, "binned_exact_filtered_tomograms_folder", obj.log_file_id); + end + end + + if obj.configuration.generate_nad_filtered_tomograms == true + nad_filter_output_iterations_list = string(obj.configuration.nad_filter_output_iterations_list); + disp("INFO: tomograms with NAD filter (at iterations: " + strjoin(nad_filter_output_iterations_list, ",") + ") will be generated."); + + nad_filtered_tomogram_destination = obj.output_path + string(filesep) + name + "_nadf.rec"; + + if isfield(obj.configuration, "nad_filter_number_of_iterations") && obj.configuration.nad_filter_number_of_iterations ~= -1 + iter_num_command_snippet = " -n " + num2str(obj.configuration.nad_filter_number_of_iterations); + else + iter_num_command_snippet = ""; + end + + if isfield(obj.configuration, "nad_filter_sigma_for_smoothing") && obj.configuration.nad_filter_sigma_for_smoothing ~= -1 + smoothing_sigma_command_snippet = " -s " + num2str(obj.configuration.nad_filter_sigma_for_smoothing); + else + smoothing_sigma_command_snippet = ""; + end + + if isfield(obj.configuration, "nad_filter_threshold_for_gradients") && obj.configuration.nad_filter_threshold_for_gradients ~= -1 + gradients_threshold_command_snippet = " -k " + num2str(obj.configuration.nad_filter_threshold_for_gradients); + else + gradients_threshold_command_snippet = ""; + end + + command = "nad_eed_3d"... + + " -i " + strjoin(nad_filter_output_iterations_list, ",")... + + iter_num_command_snippet... + + smoothing_sigma_command_snippet... + + gradients_threshold_command_snippet... + + " " + rotated_tomogram_destination... + + " " + nad_filtered_tomogram_destination; + executeCommand(command, false, obj.log_file_id); + + nad_filtered_tomograms = dir(nad_filtered_tomogram_destination + '*'); + for file_id = 1:length(nad_filtered_tomograms) + nad_filtered_tomogram_destination_iter = nad_filtered_tomograms(file_id).folder + string(filesep) + nad_filtered_tomograms(file_id).name; + filename_split = strsplit(nad_filtered_tomogram_destination_iter, '-'); + iter_num_str = filename_split(end); + nad_filtered_tomogram_destination_iter_new = obj.output_path + string(filesep) + name + "_nadf_" + iter_num_str + ".rec"; + movefile(nad_filtered_tomogram_destination_iter, nad_filtered_tomogram_destination_iter_new); end end @@ -606,107 +674,108 @@ % end end - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") && ~isempty(binned_dose_weighted_tilt_stacks) - binned_dose_weighted_tilt_stacks_tmp = binned_dose_weighted_tilt_stacks(find(contains({binned_dose_weighted_tilt_stacks.name}, name))); - disp("INFO: dose weighted tomograms will be generated."); - - dose_weighted_tomogram_destination = obj.output_path + string(filesep) + name + "_unrotated_dw.rec"; - - command = "tilt -InputProjections " + binned_dose_weighted_tilt_stacks_tmp.folder + string(filesep) + binned_dose_weighted_tilt_stacks_tmp.name... - + " -OutputFile " + dose_weighted_tomogram_destination... - + " -TILTFILE " + tlt_out_name... - + " -THICKNESS " + num2str(obj.configuration.reconstruction_thickness / splitted_binning, '%.f'); - %+ " -ExactFilterSize " + obj.configuration.exact_filter_size; - - if obj.configuration.set_up.gpu > 0 - command = command + " -UseGPU " + obj.configuration.set_up.gpu; - end - - if isfield(obj.configuration, "exclude_lists") && isfield(obj.configuration.exclude_lists, name) - command = command + " -EXCLUDELIST2 " + strjoin(strsplit(num2str(obj.configuration.exclude_lists.(name))), ","); - else - fid_files = getFilePathsFromLastBatchruntomoRun(obj.configuration, "fid"); - executeCommand("model2point " + fid_files{1} + " " + obj.output_path + filesep + "fiducial.point", false, obj.log_file_id); - fiducials = dlmread(obj.output_path + filesep + "fiducial.point"); - projection_ids = unique(fiducials(:,3)) + 1; - if ~isfield(obj.configuration, "tilt_index_angle_mapping") || ~isfield(obj.configuration.tilt_index_angle_mapping, strjoin(splitted_name(1:2), "_")) - previous_projection_ids_logical = obj.configuration.tomograms.(strjoin(splitted_name(1:2), "_")).tilt_index_angle_mapping(3,:); - else - previous_projection_ids_logical = obj.configuration.tilt_index_angle_mapping.(strjoin(splitted_name(1:2), "_"))(3,:); - end - previous_projection_ids_logical(previous_projection_ids_logical == 0) = []; - projection_ids_logical = zeros([1 length(previous_projection_ids_logical)]); - projection_ids_logical(projection_ids) = 1; - final_projections = find(~projection_ids_logical); - if ~isempty(strjoin(strsplit(num2str(final_projections)), ",")) - command = command + " -EXCLUDELIST2 " + strjoin(strsplit(num2str(final_projections)), ","); - end - end - - executeCommand(command, false, obj.log_file_id); - - dose_weighted_rotated_tomogram_destination = obj.output_path + string(filesep) + name + "_dw.rec"; - - executeCommand("trimvol -rx " + dose_weighted_tomogram_destination... - + " " + dose_weighted_rotated_tomogram_destination, false, obj.log_file_id); - delete(dose_weighted_tomogram_destination); - if contains(name, obj.configuration.ctf_corrected_stack_suffix) || obj.configuration.use_ctf_corrected_stack == true - createSymbolicLinkInStandardFolder(obj.configuration, dose_weighted_rotated_tomogram_destination, "ctf_corrected_binned_dose_weighted_tomograms_folder", obj.log_file_id); - else - createSymbolicLinkInStandardFolder(obj.configuration, dose_weighted_rotated_tomogram_destination, "binned_dose_weighted_tomograms_folder", obj.log_file_id); - end - end - - if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") && ~isempty(binned_dose_weighted_sum_tilt_stacks) - binned_dose_weighted_sum_tilt_stacks_tmp = binned_dose_weighted_sum_tilt_stacks(find(contains({binned_dose_weighted_sum_tilt_stacks.name}, name))); - disp("INFO: dose weighted sum tomograms will be generated."); - - dose_weighted_sum_tomogram_destination = obj.output_path + string(filesep) + name + "_dws.st"; - - command = "tilt -InputProjections " + binned_dose_weighted_sum_tilt_stacks_tmp.folder + string(filesep) + binned_dose_weighted_sum_tilt_stacks_tmp.name... - + " -OutputFile " + dose_weighted_sum_tomogram_destination... - + " -TILTFILE " + tlt_out_name... - + " -THICKNESS " + num2str(obj.configuration.reconstruction_thickness / splitted_binning, '%.f'); - %+ " -ExactFilterSize " + obj.configuration.exact_filter_size; - - if obj.configuration.set_up.gpu > 0 - command = command + " -UseGPU " + obj.configuration.set_up.gpu; - end - - if isfield(obj.configuration, "exclude_lists") && isfield(obj.configuration.exclude_lists, name) - command = command + " -EXCLUDELIST2 " + strjoin(strsplit(num2str(obj.configuration.exclude_lists.(name))), ","); - else - fid_files = getFilePathsFromLastBatchruntomoRun(obj.configuration, "fid"); - executeCommand("model2point " + fid_files{1} + " " + obj.output_path + filesep + "fiducial.point", false, obj.log_file_id); - fiducials = dlmread(obj.output_path + filesep + "fiducial.point"); - projection_ids = unique(fiducials(:,3)) + 1; - if ~isfield(obj.configuration, "tilt_index_angle_mapping") || ~isfield(obj.configuration.tilt_index_angle_mapping, strjoin(splitted_name(1:2), "_")) - previous_projection_ids_logical = obj.configuration.tomograms.(strjoin(splitted_name(1:2), "_")).tilt_index_angle_mapping(3,:); - else - previous_projection_ids_logical = obj.configuration.tilt_index_angle_mapping.(strjoin(splitted_name(1:2), "_"))(3,:); - end - previous_projection_ids_logical(previous_projection_ids_logical == 0) = []; - projection_ids_logical = zeros([1 length(previous_projection_ids_logical)]); - projection_ids_logical(projection_ids) = 1; - final_projections = find(~projection_ids_logical); - if ~isempty(strjoin(strsplit(num2str(final_projections)), ",")) - command = command + " -EXCLUDELIST2 " + strjoin(strsplit(num2str(final_projections)), ","); - end - end - - executeCommand(command, false, obj.log_file_id); - - dose_weighted_sum_rotated_tomogram_destination = obj.output_path + string(filesep) + name + "_dws.rec"; - - executeCommand("trimvol -rx " + dose_weighted_sum_tomogram_destination... - + " " + dose_weighted_sum_rotated_tomogram_destination, false, obj.log_file_id); - delete(dose_weighted_sum_tomogram_destination); - if contains(name, obj.configuration.ctf_corrected_stack_suffix) || obj.configuration.use_ctf_corrected_stack == true - createSymbolicLinkInStandardFolder(obj.configuration, dose_weighted_sum_rotated_tomogram_destination, "ctf_corrected_binned_dose_weighted_sum_tomograms_folder", obj.log_file_id); - else - createSymbolicLinkInStandardFolder(obj.configuration, dose_weighted_sum_rotated_tomogram_destination, "binned_dose_weighted_sum_tomograms_folder", obj.log_file_id); - end - end + % switched off before refactoring +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_files") && ~isempty(binned_dose_weighted_tilt_stacks) +% binned_dose_weighted_tilt_stacks_tmp = binned_dose_weighted_tilt_stacks(find(contains({binned_dose_weighted_tilt_stacks.name}, name))); +% disp("INFO: dose weighted tomograms will be generated."); +% +% dose_weighted_tomogram_destination = obj.output_path + string(filesep) + name + "_unrotated_dw.rec"; +% +% command = "tilt -InputProjections " + binned_dose_weighted_tilt_stacks_tmp.folder + string(filesep) + binned_dose_weighted_tilt_stacks_tmp.name... +% + " -OutputFile " + dose_weighted_tomogram_destination... +% + " -TILTFILE " + tlt_out_name... +% + " -THICKNESS " + num2str(obj.configuration.reconstruction_thickness / splitted_binning, '%.f'); +% %+ " -ExactFilterSize " + obj.configuration.exact_filter_size; +% +% if obj.configuration.set_up.gpu > 0 +% command = command + " -UseGPU " + obj.configuration.set_up.gpu; +% end +% +% if isfield(obj.configuration, "exclude_lists") && isfield(obj.configuration.exclude_lists, name) +% command = command + " -EXCLUDELIST2 " + strjoin(strsplit(num2str(obj.configuration.exclude_lists.(name))), ","); +% else +% fid_files = getFilePathsFromLastBatchruntomoRun(obj.configuration, "fid"); +% executeCommand("model2point " + fid_files{1} + " " + obj.output_path + filesep + "fiducial.point", false, obj.log_file_id); +% fiducials = dlmread(obj.output_path + filesep + "fiducial.point"); +% projection_ids = unique(fiducials(:,3)) + 1; +% if ~isfield(obj.configuration, "tilt_index_angle_mapping") || ~isfield(obj.configuration.tilt_index_angle_mapping, strjoin(splitted_name(1:2), "_")) +% previous_projection_ids_logical = obj.configuration.tomograms.(strjoin(splitted_name(1:2), "_")).tilt_index_angle_mapping(3,:); +% else +% previous_projection_ids_logical = obj.configuration.tilt_index_angle_mapping.(strjoin(splitted_name(1:2), "_"))(3,:); +% end +% previous_projection_ids_logical(previous_projection_ids_logical == 0) = []; +% projection_ids_logical = zeros([1 length(previous_projection_ids_logical)]); +% projection_ids_logical(projection_ids) = 1; +% final_projections = find(~projection_ids_logical); +% if ~isempty(strjoin(strsplit(num2str(final_projections)), ",")) +% command = command + " -EXCLUDELIST2 " + strjoin(strsplit(num2str(final_projections)), ","); +% end +% end +% +% executeCommand(command, false, obj.log_file_id); +% +% dose_weighted_rotated_tomogram_destination = obj.output_path + string(filesep) + name + "_dw.rec"; +% +% executeCommand("trimvol -rx " + dose_weighted_tomogram_destination... +% + " " + dose_weighted_rotated_tomogram_destination, false, obj.log_file_id); +% delete(dose_weighted_tomogram_destination); +% if contains(name, obj.configuration.ctf_corrected_stack_suffix) || obj.configuration.use_ctf_corrected_stack == true +% createSymbolicLinkInStandardFolder(obj.configuration, dose_weighted_rotated_tomogram_destination, "ctf_corrected_binned_dose_weighted_tomograms_folder", obj.log_file_id); +% else +% createSymbolicLinkInStandardFolder(obj.configuration, dose_weighted_rotated_tomogram_destination, "binned_dose_weighted_tomograms_folder", obj.log_file_id); +% end +% end +% +% if isfield(obj.configuration.tomograms.(field_names{obj.configuration.set_up.j}), "motion_corrected_dose_weighted_sum_files") && ~isempty(binned_dose_weighted_sum_tilt_stacks) +% binned_dose_weighted_sum_tilt_stacks_tmp = binned_dose_weighted_sum_tilt_stacks(find(contains({binned_dose_weighted_sum_tilt_stacks.name}, name))); +% disp("INFO: dose weighted sum tomograms will be generated."); +% +% dose_weighted_sum_tomogram_destination = obj.output_path + string(filesep) + name + "_dws.st"; +% +% command = "tilt -InputProjections " + binned_dose_weighted_sum_tilt_stacks_tmp.folder + string(filesep) + binned_dose_weighted_sum_tilt_stacks_tmp.name... +% + " -OutputFile " + dose_weighted_sum_tomogram_destination... +% + " -TILTFILE " + tlt_out_name... +% + " -THICKNESS " + num2str(obj.configuration.reconstruction_thickness / splitted_binning, '%.f'); +% %+ " -ExactFilterSize " + obj.configuration.exact_filter_size; +% +% if obj.configuration.set_up.gpu > 0 +% command = command + " -UseGPU " + obj.configuration.set_up.gpu; +% end +% +% if isfield(obj.configuration, "exclude_lists") && isfield(obj.configuration.exclude_lists, name) +% command = command + " -EXCLUDELIST2 " + strjoin(strsplit(num2str(obj.configuration.exclude_lists.(name))), ","); +% else +% fid_files = getFilePathsFromLastBatchruntomoRun(obj.configuration, "fid"); +% executeCommand("model2point " + fid_files{1} + " " + obj.output_path + filesep + "fiducial.point", false, obj.log_file_id); +% fiducials = dlmread(obj.output_path + filesep + "fiducial.point"); +% projection_ids = unique(fiducials(:,3)) + 1; +% if ~isfield(obj.configuration, "tilt_index_angle_mapping") || ~isfield(obj.configuration.tilt_index_angle_mapping, strjoin(splitted_name(1:2), "_")) +% previous_projection_ids_logical = obj.configuration.tomograms.(strjoin(splitted_name(1:2), "_")).tilt_index_angle_mapping(3,:); +% else +% previous_projection_ids_logical = obj.configuration.tilt_index_angle_mapping.(strjoin(splitted_name(1:2), "_"))(3,:); +% end +% previous_projection_ids_logical(previous_projection_ids_logical == 0) = []; +% projection_ids_logical = zeros([1 length(previous_projection_ids_logical)]); +% projection_ids_logical(projection_ids) = 1; +% final_projections = find(~projection_ids_logical); +% if ~isempty(strjoin(strsplit(num2str(final_projections)), ",")) +% command = command + " -EXCLUDELIST2 " + strjoin(strsplit(num2str(final_projections)), ","); +% end +% end +% +% executeCommand(command, false, obj.log_file_id); +% +% dose_weighted_sum_rotated_tomogram_destination = obj.output_path + string(filesep) + name + "_dws.rec"; +% +% executeCommand("trimvol -rx " + dose_weighted_sum_tomogram_destination... +% + " " + dose_weighted_sum_rotated_tomogram_destination, false, obj.log_file_id); +% delete(dose_weighted_sum_tomogram_destination); +% if contains(name, obj.configuration.ctf_corrected_stack_suffix) || obj.configuration.use_ctf_corrected_stack == true +% createSymbolicLinkInStandardFolder(obj.configuration, dose_weighted_sum_rotated_tomogram_destination, "ctf_corrected_binned_dose_weighted_sum_tomograms_folder", obj.log_file_id); +% else +% createSymbolicLinkInStandardFolder(obj.configuration, dose_weighted_sum_rotated_tomogram_destination, "binned_dose_weighted_sum_tomograms_folder", obj.log_file_id); +% end +% end end end end diff --git a/modules/RefineFiducialModel.m b/modules/RefineFiducialModel.m old mode 100755 new mode 100644 index b73832a..3288699 --- a/modules/RefineFiducialModel.m +++ b/modules/RefineFiducialModel.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef RefineFiducialModel < Module methods function obj = RefineFiducialModel(configuration) diff --git a/modules/RelionAlignmentProject.m b/modules/RelionAlignmentProject.m index a9bbb61..c787c55 100644 --- a/modules/RelionAlignmentProject.m +++ b/modules/RelionAlignmentProject.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef RelionAlignmentProject < Module methods function obj = RelionAlignmentProject(configuration) diff --git a/modules/SortFiles.m b/modules/SortFiles.m old mode 100755 new mode 100644 index 5511faf..65b8cb5 --- a/modules/SortFiles.m +++ b/modules/SortFiles.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef SortFiles < Module methods function obj = SortFiles(configuration) diff --git a/modules/TemplateGenerationFromFile.m b/modules/TemplateGenerationFromFile.m old mode 100755 new mode 100644 index 9ffd8bd..9b8827d --- a/modules/TemplateGenerationFromFile.m +++ b/modules/TemplateGenerationFromFile.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef TemplateGenerationFromFile < Module methods function obj = TemplateGenerationFromFile(configuration) diff --git a/modules/TemplateMatchingPostProcessing.m b/modules/TemplateMatchingPostProcessing.m old mode 100755 new mode 100644 index 616708f..3bc1e21 --- a/modules/TemplateMatchingPostProcessing.m +++ b/modules/TemplateMatchingPostProcessing.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef TemplateMatchingPostProcessing < Module methods function obj = TemplateMatchingPostProcessing(configuration) diff --git a/modules/TomoAlign.m b/modules/TomoAlign.m old mode 100755 new mode 100644 index 466805c..da38eda --- a/modules/TomoAlign.m +++ b/modules/TomoAlign.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef TomoAlign < Module methods function obj = TomoAlign(configuration) diff --git a/pipeline/GridEnginePipeline.m b/pipeline/GridEnginePipeline.m old mode 100755 new mode 100644 index f340888..27eff73 --- a/pipeline/GridEnginePipeline.m +++ b/pipeline/GridEnginePipeline.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef GridEnginePipeline < Pipeline methods function obj = GridEnginePipeline(configuration_path, default_configuration_path) diff --git a/pipeline/LocalLivePipeline.m b/pipeline/LocalLivePipeline.m new file mode 100644 index 0000000..61d41e9 --- /dev/null +++ b/pipeline/LocalLivePipeline.m @@ -0,0 +1,854 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +classdef LocalLivePipeline < Pipeline + methods + function obj = LocalLivePipeline(configuration_path, default_configuration_path) + if nargin == 0 + configuration_path = ""; + default_configuration_path = ""; + elseif nargin == 1 + default_configuration_path = ""; + end + obj@Pipeline(configuration_path, default_configuration_path); + end + + function execute(obj, tomogram_begin, tomogram_end, pipeline_ending_step, gpu) + disp("INFO: Executing pipeline..."); + + if ~isempty(obj.default_configuration) + configuration = obj.initializeDefaults(); + else + configuration = obj.configuration; + end + + if nargin == 1 + tomogram_begin = -1; + tomogram_end = -1; + pipeline_ending_step = -1; + gpu = -2; + elseif nargin == 2 + tomogram_end = -1; + pipeline_ending_step = -1; + gpu = -2; + elseif nargin == 3 + pipeline_ending_step = -1; + gpu = -2; + elseif nargin == 4 + gpu = -2; + end + + configuration.general.tomogram_begin = tomogram_begin; + configuration.general.tomogram_end = tomogram_end; + + configuration.general.live_data_mode = true; + + pipeline_definition = fieldnames(configuration); + +% if configuration.general.random_number_generator_seed > -1 +% if configuration.general.random_number_generator_seed == 0 +% rng("default") +% else +% rng(configuration.general.random_number_generator_seed); +% end +% end + + % obj.semaphore_key = randi(999999); + + % try + % semaphore('destroy', obj.semaphore_key, 1); + % catch + % end + % + % semaphore('create', obj.semaphore_key, 1); + + + + if configuration.general.cuda_forward_compatibility == true && ~verLessThan("matlab", "9.9") + parallel.gpu.enableCUDAForwardCompatibility(true) + end + + distcomp.feature( 'LocalUseMpiexec', false ); + % NOTE: not really useful, because toolkit needs to be run from + % project folder or needs to be added to path + if configuration.general.data_path == "" + configuration.general.data_path = string(pwd); + configuration.general.processing_path = configuration.general.data_path; + end + + if configuration.general.processing_path ~= "" + processing_path = configuration.general.processing_path; + else + configuration.general.processing_path = configuration.general.data_path; + processing_path = configuration.general.processing_path; + end + + disp("INFO:PROCESSING_PATH: " + configuration.general.processing_path); + disp("INFO:DATA_PATH: " + configuration.general.data_path); + % dynamic_configuration = struct(); + + if configuration.general.debug == true + % TODO: check return value + if exist(processing_path + string(filesep) + configuration.general.output_folder, "dir") + rmdir(processing_path + string(filesep) + configuration.general.output_folder, "s"); + end + + if exist(processing_path + string(filesep) + configuration.general.scratch_folder, "dir") + rmdir(processing_path + string(filesep) + configuration.general.scratch_folder, "s"); + end + + end + + output_path = processing_path + string(filesep) + configuration.general.output_folder; + + if ~exist(output_path, "dir") + [status_mkdir, message, message_id] = mkdir(output_path); + end + + pipeline_log_file_path = output_path + string(filesep) + "pipeline.log"; + + if fileExists(pipeline_log_file_path) + log_file_id = fopen(pipeline_log_file_path, "a"); + else + log_file_id = fopen(pipeline_log_file_path, "w"); + end + + meta_data_folder_path = getMetaDataFolderPath(configuration.general); + + if ~exist(meta_data_folder_path, "dir") + [status_mkdir, message, message_id] = mkdir(meta_data_folder_path); + end + + meta_data_file_path = getMetaDataFilePath(configuration.general); + [folder, name, extension] = fileparts(meta_data_file_path); + + if fileExists(folder + string(filesep) + name + ".json") %exist(meta_data_file_path, "file") == 2 || + configuration_history = obj.loadJSON(folder + string(filesep) + name + ".json"); + % try + % load(meta_data_file_path, "configuration_history"); + % + % catch + % + % try + % load(folder + string(filesep) + name + "_backup" + extension, "configuration_history"); + % catch + % load(folder + string(filesep) + name + "_backup_backup" + extension, "configuration_history"); + % end + % + % end + + configuration.general = obj.mergeConfigurations(configuration.general, configuration_history.general, 0, "Pipeline"); + else + configuration_history = struct(); + configuration_history.processing_step_times = struct; + end + + % TODO:NOTE: not needed + % if configuration.general.wipe_cache == true + % if exist(meta_data_path, "file") + % % TODO: Check status and message and message_id + % [status, message, message_id] = rmdir(meta_data_path, "s"); + % end + % end + + + + if obj.configuration_path ~= "" + [success, message, message_id] = copyfile(obj.configuration_path, folder + string(filesep) + "project.json"); + end + + if obj.default_configuration_path ~= "" + [success, message, message_id] = copyfile(obj.default_configuration_path, folder + string(filesep) + "defaults.json"); + end + + % TODO:NOTE: last processed tomogram number needs to be loaded + % TODO: look if this is needed + if isfield(configuration.general, "tomogram_indices_original") + tomogram_indices = configuration.general.tomogram_indices_original; + elseif isfield(configuration.general, "tomogram_indices") && ~isempty(configuration.general.tomogram_indices) + tomogram_indices = configuration.general.tomogram_indices; + elseif isfield(configuration.general, "tomogram_begin")... + && isfield(configuration.general, "tomogram_end")... + && 0 < configuration.general.tomogram_begin... + && 0 < configuration.general.tomogram_end... + && configuration.general.tomogram_end >= configuration.general.tomogram_begin... + && configuration.general.tomogram_step ~= 0 + tomogram_indices = configuration.general.tomogram_begin:configuration.general.tomogram_step:configuration.general.tomogram_end; + else + tomogram_indices = []; + end + + if isfield(configuration.general, "tomogram_indices_processed") + tomogram_indices_processed = configuration.general.tomogram_indices_processed; + else + tomogram_indices_processed = []; + end + + tomogram_status = {}; + dynamic_configuration = []; + % "listening" mode + while true + + if isfield(configuration.general, "skip_data_check") && configuration.general.skip_data_check == true + error("ERROR: skip_data_check cannot be used in live data processing mode!"); +% dynamic_configuration = struct; +% dynamic_configuration.file_count = configuration.general.file_count; +% if ~isfield(configuration, "starting_tomogram") +% dynamic_configuration.starting_tomogram = 1; +% else +% dynamic_configuration.starting_tomogram = configuration.starting_tomogram; +% end +% dynamic_configuration.tomograms_count = configuration.general.tomograms_count; +% file_count_changed = false; + elseif ~isempty(tomogram_indices) && all(ismember(tomogram_indices,tomogram_indices_processed)) + disp("INFO: All requested tilt series were processed!"); + break; + else + [file_list, ~] = getOriginalMRCsorTIFs(configuration.general, false); + if (isempty(dynamic_configuration) && ~isempty(file_list)) || (~isempty(dynamic_configuration) && isfield(dynamic_configuration, "file_count") && dynamic_configuration.file_count < length(file_list)) + [dynamic_configuration, ~] = getUnprocessedTomograms(configuration.general, log_file_id); + else + continue; + end + end + + % obj.saveJSON(folder + string(filesep) + "tomogram_meta_data.json", dynamic_configuration); +% sucess_files_to_be_deleted = dir(output_path + string(filesep) + "*" + string(filesep) + "SUCCESS"); + +% if file_count_changed == true +% sucess_files_to_be_deleted = dir(output_path + string(filesep) + "*" + string(filesep) + "SUCCESS"); +% +% for i = 1:length(sucess_files_to_be_deleted) +% delete(sucess_files_to_be_deleted(i).folder + string(filesep) + sucess_files_to_be_deleted(i).name); +% end +% +% elseif file_count_changed == false && length(sucess_files_to_be_deleted) < length(pipeline_definition) +% elseif file_count_changed == false && isfield(configuration.general, "skip_data_check") && configuration.general.skip_data_check == true +% else +% disp("INFO: File count has not changed therefor further execution of the pipeline is abandoned!") +% break; +% end + +% if isfield(configuration_history, "general") +% configuration_history.general = obj.mergeConfigurations(configuration_history.general, dynamic_configuration, 0, "dynamic"); +% else +% configuration_history.general = dynamic_configuration; +% end +% +% configuration.general = obj.mergeConfigurations(configuration.general, configuration_history.general, 0, "Pipeline"); + + % tomogram_names = fieldnames(configuration.general.tomograms); + + % NOTE: possibly overwrites the currently loaded file + %save(meta_data_file_path, "configuration_history", "-v7.3"); + % obj.parforSave(meta_data_file_path, configuration_history); + + % for j = 1:length(tomogram_names) + % tomogram_number = j; + % % TODO:NOTE: what if new pipeline steps were added? + % if ~isfield(configuration.general.tomograms.(tomogram_names{tomogram_number}), "processed_pipeline_steps") + % configuration.general.tomograms.(tomogram_names{tomogram_number}).processed_pipeline_steps = zeros(length(pipeline_definition)-1, 1); + % else + % if length(pipeline_definition) > length(configuration.general.tomograms.(tomogram_names{tomogram_number}).processed_pipeline_steps) + % % TODO: needs to be tested if count pipeline steps + % % is changed and processed pipelinesteps are kept + % processed_pipeline_steps_tmp = configuration.general.tomograms.(tomogram_names{tomogram_number}).processed_pipeline_steps; + % configuration.general.tomograms.(tomogram_names{tomogram_number}).processed_pipeline_steps = zeros(length(pipeline_definition), 1); + % configuration.general.tomograms.(tomogram_names{tomogram_number}).processed_pipeline_steps(1:length(processed_pipeline_steps_tmp)) = processed_pipeline_steps_tmp; + % elseif length(pipeline_definition) < configuration.general.tomograms.(tomogram_names{tomogram_number}).processed_pipeline_steps + % error("ERROR: reducing pipeline steps is not implemented!"); + % else + % disp("NOTE: pipeline stayed unchanged, nothing to be done here!"); + % end + % end + % end + + tomogram_indices_available = 1:dynamic_configuration.tomograms_count; + if ~isempty(tomogram_indices) + tomogram_indices_to_check = tomogram_indices_available(ismember(tomogram_indices_available, tomogram_indices)); + else + tomogram_indices_to_check = tomogram_indices_available; + end + tomogram_to_process_mask = zeros([1 dynamic_configuration.tomograms_count]); + tomogram_to_process_mask(tomogram_indices_to_check) = 1; + + if ~isfield(dynamic_configuration, "tomograms") || isempty(dynamic_configuration.tomograms) + dynamic_configuration.tomograms = configuration.general.tomograms; + end + tomogram_names = fieldnames(dynamic_configuration.tomograms); + + tomogram_enough_files_mask = zeros([1 dynamic_configuration.tomograms_count]); + for tomogram_idx = tomogram_indices_to_check + tomogram_enough_files_mask(tomogram_idx) = ~dynamic_configuration.tomograms.(tomogram_names{tomogram_idx}).skipped; + + if ~tomogram_enough_files_mask(tomogram_idx) + last_collected_frame_datetime_string = dynamic_configuration.tomograms.(tomogram_names{tomogram_idx}).last_collected_frame_date + " " + dynamic_configuration.tomograms.(tomogram_names{tomogram_idx}).last_collected_frame_time; + + if isfield(configuration.general, "date_position") && configuration.general.date_position ~= 0 + month_day_format = "MMMdd"; + else + month_day_format = "yyyy-MM-dd"; + end + if isfield(configuration.general, "time_position") && configuration.general.time_position ~= 0 + time_format = "HH.mm.ss"; + else + time_format = "HH:mm:ss.SSSSSSSSS"; + end + + last_collected_frame_datetime = datetime(last_collected_frame_datetime_string, "Format", month_day_format + " " + time_format, "TimeZone", "local"); + current_datetime = datetime("now", "Format", month_day_format + " " + time_format, "TimeZone", "local"); + tomogram_last_collected_frame_criteria = minutes(current_datetime-last_collected_frame_datetime) > configuration.general.listening_time_threshold_in_minutes; + tomogram_enough_files_mask(tomogram_idx) = tomogram_last_collected_frame_criteria; + end + + end + + tomogram_processed_mask = zeros([1 dynamic_configuration.tomograms_count]); + tomogram_processed_mask(tomogram_indices_processed) = 1; + + tomogram_mask = tomogram_to_process_mask & tomogram_enough_files_mask & ~tomogram_processed_mask; + + if ~any(tomogram_mask) + disp("INFO: No new fully collected tilt series to process!"); + disp("INFO: Continue listening..."); + continue; + end + + disp("INFO: Starting processing of the newly collected tilt series..."); + previous_tomogram_status = tomogram_mask; + dynamic_configuration.tomogram_indices = tomogram_indices_to_check; + dynamic_configuration.tomogram_indices_original = tomogram_indices; + + + + % add tomograms to be processed to the list of + % already processed tomograms + tomogram_indices_to_be_processed = tomogram_indices_to_check(tomogram_mask(tomogram_indices_to_check)==1); +% if ~isempty(tomogram_indices_processed) +% tomogram_indices_processed_extention_mask = ~ismember(tomogram_indices_to_be_processed, tomogram_indices_processed); +% tomogram_indices_processed_extention = tomogram_indices_to_be_processed(tomogram_indices_processed_extention_mask); +% dynamic_configuration.tomogram_indices_processed = [tomogram_indices_processed; tomogram_indices_processed_extention']; +% else +% dynamic_configuration.tomogram_indices_processed = tomogram_indices_to_be_processed'; +% end +% tomogram_indices_processed = dynamic_configuration.tomogram_indices_processed; + + + + if isfield(configuration_history, "general") + configuration_history.general = obj.mergeConfigurations(configuration_history.general, dynamic_configuration, 0, "dynamic"); + else + configuration_history.general = dynamic_configuration; + end + + configuration.general = obj.mergeConfigurations(configuration.general, configuration_history.general, 0, "Pipeline"); + sucess_files_to_be_deleted = dir(output_path + string(filesep) + "*" + string(filesep) + "SUCCESS"); + for i = 1:length(sucess_files_to_be_deleted) + delete(sucess_files_to_be_deleted(i).folder + string(filesep) + sucess_files_to_be_deleted(i).name); + end + + tomogram_status = {}; + % meta_data_file_path = getMetaDataFilePath(configuration.general); + + for i = 1:length(pipeline_definition) + % TODO: Make it independent of position, rrather not, + % delete comment + if (i == 1 && obj.pipeline_definition{i} == "general") + continue; + elseif (i == 1 && obj.pipeline_definition{i} ~= "general") + error("ERROR: General section in configuration missing or" ... + + " it is not in the first position!"); + end + + configuration_history.processing_step_times.("Step_" + (i - 1) + "_" + pipeline_definition{i}) = struct; + + if ~isfield(configuration_history, pipeline_definition{i}) + configuration_history.(pipeline_definition{i}) = struct; + end + + if ~isempty(fieldnames(dynamic_configuration)) + configuration.(pipeline_definition{i}) = obj.mergeConfigurations(configuration.(pipeline_definition{i}), dynamic_configuration, 0, "dynamic"); + end + + % NOTE: Everything is merged into general + % configuration, this means that fields defined in the + % pipeline processing step are overwriting fields from + % general configuration + merged_configuration = obj.mergeConfigurations(... + configuration.general, ... + configuration.(pipeline_definition{i}), i - 1, obj.pipeline_definition{i}); + + merged_configuration = obj.fillSetUpStructPipelineStep(merged_configuration, i); + % TODO: perhaps should also look for corresponding + % scratch folder + + merged_configuration.output_path = processing_path + string(filesep) + merged_configuration.pipeline_step_output_folder; + merged_configuration.scratch_path = processing_path + string(filesep) + merged_configuration.pipeline_step_scratch_folder; + ignore_success_files = merged_configuration.ignore_success_files; + + time_file_path = merged_configuration.output_path + string(filesep) + "TIME"; + success_file_path = merged_configuration.output_path + string(filesep) + "SUCCESS"; + failure_file_path = merged_configuration.output_path + string(filesep) + "FAILURE"; + if gpu ~= -2 + merged_configuration.gpu = gpu; + end + + if fileExists(success_file_path) + success_file_id = fopen(success_file_path, "r"); + status_flags = textscan(success_file_id, "%s"); + status_flags = status_flags{1}; + status_flags = [str2double(status_flags)]'; + if length(status_flags) < length(previous_tomogram_status) + status_flags_tmp = zeros([1 length(previous_tomogram_status)]); + status_flags_tmp(1:length(status_flags)) = status_flags; + status_flags = status_flags_tmp; + end + if any(~status_flags & previous_tomogram_status) && pipeline_ending_step ~= -1 + status_flags = double(status_flags | previous_tomogram_status); + previous_tomogram_status = status_flags; + ignore_success_files = true; + end + tomogram_status{i - 1} = status_flags & tomogram_mask; + end + + + + if ignore_success_files == false && fileExists(success_file_path) + % success_file_id = fopen(success_file_path); + % status_flags = textscan(success_file_id, "%s"); + % status_flags = status_flags{1}; + % status_flags = [str2double(status_flags)]'; + % tomogram_status{i - 1} = status_flags; + if obj.pipeline_definition{i} ~= "StopPipeline" + dynamic_configuration_in = dynamic_configuration; + dynamic_configuration_out = obj.finishPipelineStep(... + dynamic_configuration, pipeline_definition{i}, ... + configuration_history, i); + dynamic_configuration = dynamic_configuration_out; + end + disp("INFO: Skipping pipeline step (" + obj.pipeline_definition{i} + ") due to availability of a SUCCESS file!") + if pipeline_ending_step + 1 == i + disp("INFO: processing reached given pipeline step " + pipeline_ending_step); + return; + else + continue; + end + elseif fileExists(failure_file_path) && merged_configuration.ignore_success_files == false + disp("INFO: Aborting execution of the pipeline step (" + obj.pipeline_definition{i} + ") due to availability of a FAILURE file!"); + return; + else + %configuration_history.(pipelineDefinition{i}) = struct; + % if i == 2 + % previous_tomogram_status = {ones([1 dynamic_configuration.tomograms_count])}; + % else + if i > 2 + previous_tomogram_status = tomogram_status{i - 2}; + end + + processing_step_start_time = tic; + + % TODO: pack module execution path description somewhere else + if isfield(merged_configuration, "execution_method")... + && (merged_configuration.execution_method == "once"... + || merged_configuration.execution_method == "in_order"... + || merged_configuration.execution_method == "sequential"... + || merged_configuration.execution_method == "parallel") + + if (merged_configuration.execution_method == "in_order"... + || merged_configuration.execution_method == "parallel") && pipeline_ending_step ~= -1 + pool_folder = merged_configuration.processing_path + string(filesep) + merged_configuration.output_folder + string(filesep) + "jobs" + string(filesep) + "pool_" + merged_configuration.tomogram_end; + if ~exist(pool_folder, "dir") + [status_mkdir, message, message_id] = mkdir(pool_folder); + end + % if merged_configuration.execution_method == "parallel" + % generatePool(merged_configuration.cpu_fraction, false, pool_folder); + % elseif merged_configuration.execution_method == "in_order" + disp("INFO:VARIABLE:merged_configuration.environment_properties.gpu_count: " + merged_configuration.environment_properties.gpu_count); + generatePool(merged_configuration.environment_properties.gpu_count, false, pool_folder); + % end + end + [dynamic_configuration_out, tomogram_status{i - 1}] = obj.("execution_" + merged_configuration.execution_method)(merged_configuration, obj.pipeline_definition{i}, previous_tomogram_status); + elseif isfield(merged_configuration, "execution_method") && merged_configuration.execution_method == "control" + if fileExists(success_file_path) + if pipeline_ending_step + 1 == i + disp("INFO: processing reached given pipeline step " + pipeline_ending_step); + %exit(0); + return; + end + continue; + else + tomogram_status{i - 1} = tomogram_status{i - 2}; + obj.createOutputAndScratchFoldersForPipelineStep(merged_configuration); + fid = fopen(success_file_path, 'wt'); + fprintf(fid, "%s", string(num2str(tomogram_status{i - 1}))); + fclose(fid); + disp("INFO: reached control block (" + obj.pipeline_definition{i} + ") pipeline is stopping! ") + return; + end + else + error("ERROR: no execution method defined for this module in json file."); + end + + processing_step_end_time = toc(processing_step_start_time); + + dynamic_configuration = obj.mergeConfigurations(dynamic_configuration, dynamic_configuration_out, 0, "dynamic"); + + if ~isfield(configuration_history, pipeline_definition{i}) + configuration_history.(pipeline_definition{i}) = struct; + end + + configuration_history.(pipeline_definition{i}) = obj.mergeConfigurations(configuration_history.(pipeline_definition{i}), dynamic_configuration_out, 0, "dynamic"); + + + % TODO: does this condition make really sense + %if (~isfield(configuration_history.processing_step_times, "Step_" + (i - 1) + "_" + pipeline_definition{i}))... + % ||... + % (isfield(configuration_history.processing_step_times, pipeline_definition{i}) && ~fileExists(success_file_path)) + if ~isfield(configuration_history.processing_step_times.("Step_" + (i - 1) + "_" + pipeline_definition{i}), "overall_time") + configuration_history.processing_step_times.("Step_" + (i - 1) + "_" + pipeline_definition{i}).overall_time = processing_step_end_time; + else + configuration_history.processing_step_times.("Step_" + (i - 1) + "_" + pipeline_definition{i}).overall_time = ... + configuration_history.processing_step_times.("Step_" + (i - 1) + "_" + pipeline_definition{i}) + processing_step_end_time; + end + + %end + + + + + % TODO: needs revision if only one both variables is set + % if (isfield(merged_configuration, "tomogram_interval") && isempty(merged_configuration.tomogram_interval) ... + % && (isfield(merged_configuration, "tomogram_begin") && isfield(merged_configuration, "tomogram_end") && merged_configuration.tomogram_begin == -1 && merged_configuration.tomogram_end == -1)) ... + % || (isfield(merged_configuration, "tomogram_interval") && length(merged_configuration.tomogram_interval(1):merged_configuration.tomogram_interval(2):merged_configuration.tomogram_interval(3)) == length(tomogram_names) ... + % || (isfield(merged_configuration, "tomogram_begin") && isfield(merged_configuration, "tomogram_end") && isfield(merged_configuration, "tomogram_step") && length(merged_configuration.tomogram_begin:merged_configuration.tomogram_step:merged_configuration.tomogram_end) == length(tomogram_names))) + % fid = fopen(success_file_path, 'wt'); + % fprintf(fid, "%s", string(num2str(tomogram_status{i - 1}))); + % fclose(fid); + % else + if (dynamic_configuration.tomograms_count == tomogram_end && tomogram_begin == 1) || (tomogram_end == -1 && tomogram_begin == -1) + if fileExists(time_file_path) && merged_configuration.execution_method ~= "once" + fid = fopen(time_file_path, 'r'); + previous_time = textscan(fid, "%s"); + previous_time = previous_time{1}; + previous_time = str2double(previous_time); + processing_step_end_time = processing_step_end_time + previous_time; + end + fid = fopen(time_file_path, 'wt'); + fprintf(fid, "%s", string(num2str(processing_step_end_time))); + fclose(fid); + + fid = fopen(success_file_path, 'wt'); + fprintf(fid, "%s", string(num2str(tomogram_status{i - 1}))); + fclose(fid); + + combined_configuration = obj.readAndCombineConfigurationsFromFolder(merged_configuration.output_path); + obj.saveJSON(merged_configuration.output_path + string(filesep) + "partial_output.json", combined_configuration); + obj.saveJSON(merged_configuration.output_path + string(filesep) + "combined_output.json", dynamic_configuration); + obj.saveJSON(folder + string(filesep) + name + ".json", configuration_history); + % TODO: implement case for skipping whole pipeline steps, + % but what to do if new tomograms were added? add automatic an ignore + % flag? +% if isfield(configuration.general, "skip_data_check") && configuration.general.skip_data_check == true +% file_count_changed = false; +% else +% file_count_changed = getFileCountChanged(configuration.general); +% end +% +% if file_count_changed == true +% break; +% end + + end + end + if pipeline_ending_step + 1 == i + disp("INFO: processing reached given pipeline step " + pipeline_ending_step); + return; + end + end + + % update list of the already processed tomograms + if ~isempty(tomogram_indices_processed) + tomogram_indices_processed_extention_mask = ~ismember(tomogram_indices_to_be_processed, tomogram_indices_processed); + tomogram_indices_processed_extention = tomogram_indices_to_be_processed(tomogram_indices_processed_extention_mask); + dynamic_configuration.tomogram_indices_processed = [tomogram_indices_processed; tomogram_indices_processed_extention']; + else + dynamic_configuration.tomogram_indices_processed = tomogram_indices_to_be_processed'; + end + tomogram_indices_processed = dynamic_configuration.tomogram_indices_processed; + + end + disp("INFO: Execution finished!"); + end + + function [dynamic_configuration_out, status] = execution_once(obj, merged_configuration, pipeline_definition, previous_tomogram_status) + if (isfield(merged_configuration, "skip") && merged_configuration.skip == true) || (~isempty(previous_tomogram_status) && ~any(previous_tomogram_status)) + status = previous_tomogram_status; + dynamic_configuration_out = struct; + return; + end + + obj.createOutputAndScratchFoldersForPipelineStep(merged_configuration); + + obj.saveJSON(merged_configuration.output_path + string(filesep) + "input.json", merged_configuration); + + function_handle = str2func(pipeline_definition); + + disp("INFO: Executing processing step " + num2str(merged_configuration.set_up.i - 1) + ... + ": " + pipeline_definition + "..."); + + instantiated_class = function_handle(merged_configuration); + + instantiated_class = instantiated_class.setUp(); + + if merged_configuration.execute == true + instantiated_class = instantiated_class.process(); + dynamic_configuration_out = instantiated_class.dynamic_configuration; + else + dynamic_configuration_out = loadJSON(instantiated_class.output_path + string(filesep) + "output.json"); + end + + instantiated_class = instantiated_class.cleanUp(); + + status = instantiated_class.status; + + if status == 1 + success_file_path = merged_configuration.output_path + string(filesep) + "SUCCESS"; + status = previous_tomogram_status; + fid = fopen(success_file_path, 'wt'); + obj.saveJSON(instantiated_class.output_path + string(filesep) + "output.json", instantiated_class.dynamic_configuration); + elseif status == 0 + failure_file_path = merged_configuration.output_path + string(filesep) + "FAILURE"; + status = zeros(1, length(previous_tomogram_status)); + fid = fopen(failure_file_path, 'wt'); + else + error("ERROR: status " + status + " unknown "); + end + + fclose(fid); + + disp("INFO: Execution for processing step " + num2str(merged_configuration.set_up.i - 1) + ... + " (" + pipeline_definition + ") has finished!"); + end + + function [dynamic_configuration_out, status] = execution_parallel(obj, merged_configuration, pipeline_definition, previous_tomogram_status) + tomogram_names = fieldnames(merged_configuration.tomograms); + + status = cell([1 length(previous_tomogram_status)]); + for j = 1:length(previous_tomogram_status) + status{j} = 0; + end + + indices = find(previous_tomogram_status); + parfor j = 1:length(indices) + merged_configuration_tmp = fillSetUpStructIteration(merged_configuration, indices(j), previous_tomogram_status); + [dynamic_configurations_out{j}, status_tmp{j}] = iteration(merged_configuration_tmp, pipeline_definition, tomogram_names{indices(j)}, previous_tomogram_status(indices(j))); + end + + if ~any(previous_tomogram_status) + dynamic_configuration_out = struct; + else + dynamic_configuration_out = obj.combineConfigurations(dynamic_configurations_out); + end + + for k = 1:length(indices) + status{indices(k)} = status_tmp{k}; + end + status = [status{:}]; + end + + function [dynamic_configuration_out, status] = execution_in_order(obj, merged_configuration, pipeline_definition, previous_tomogram_status) + tomogram_names = fieldnames(merged_configuration.tomograms); + + counter = 0; + + % TODO: revise for better parametrization + if isfield(obj.configuration.general, "gpu_worker_multiplier")... + && (~isfield(merged_configuration, "method")... + || (isfield(merged_configuration, "method")... + && merged_configuration.method ~= "MotionCor2")) + if isscalar(merged_configuration.gpu) && merged_configuration.gpu == -1 + workers = merged_configuration.environment_properties.gpu_count * merged_configuration.configuration.gpu_worker_multiplier; + else + workers = length(merged_configuration.gpu) * merged_configuration.gpu_worker_multiplier; + end + else + if isscalar(merged_configuration.gpu) && merged_configuration.gpu == -1 + workers = merged_configuration.environment_properties.gpu_count; + else + workers = length(merged_configuration.gpu); + end + end + + status = cell([1 length(previous_tomogram_status)]); + for j = 1:length(previous_tomogram_status) + status{j} = 0; + end + + pool_folder = merged_configuration.processing_path + string(filesep) + merged_configuration.output_folder + string(filesep) + "jobs" + string(filesep) + "pool_" + merged_configuration.tomogram_end; + if ~exist(pool_folder, "dir") + [status_mkdir, message, message_id] = mkdir(pool_folder); + end + + poolobj = generatePool(workers, false, pool_folder); + + cumulative_sum_previous_tomogram_status = cumsum(previous_tomogram_status); + indices = find(previous_tomogram_status); + for j = 1:max(cumulative_sum_previous_tomogram_status) + if mod(j - 1, workers) == 0 && j > 1 + wait(f); + [dynamic_configuration_tmp, status_tmp] = fetchOutputs(f, 'UniformOutput', false); + + for k = 1:workers + dynamic_configurations_out{counter + 1} = dynamic_configuration_tmp{k}; + status{indices(counter + 1)} = status_tmp{k}; + counter = counter + 1; + end + clear f; + end + merged_configurations{j} = merged_configuration; + merged_configurations{j} = obj.fillSetUpStructIteration(merged_configurations{j}, indices(j), previous_tomogram_status); + % TODO intermediate configurations need to be saved to be + % consistent + f(mod(j - 1, workers) + 1) = ... + parfeval(poolobj, @iteration, 2, merged_configurations{j}, pipeline_definition, tomogram_names{indices(j)}, previous_tomogram_status(indices(j))); + end + + if exist("f", "var") && ~isempty(f) + wait(f); + [dynamic_configuration_tmp, status_tmp] = fetchOutputs(f, 'UniformOutput', false); + % TODO: needs to be adjusted for arbitrary number of + % gpus + for j = 1:length(dynamic_configuration_tmp) + dynamic_configurations_out{counter + 1} = dynamic_configuration_tmp{j}; + status{indices(counter + 1)} = status_tmp{j}; + counter = counter + 1; + end + + end + + if ~any(previous_tomogram_status) + dynamic_configuration_out = struct; + else + dynamic_configuration_out = obj.combineConfigurations(dynamic_configurations_out); + end + status = [status{:}]; + end + + function [dynamic_configuration_out, status] = iteration(merged_configuration, pipeline_definition, tomogram_name, previous_tomogram_status) + [dynamic_configuration_out, status] = iteration(merged_configuration, pipeline_definition, tomogram_name, previous_tomogram_status); + end + + function tomogram_names = setUpInterval(obj, merged_configuration, previous_tomogram_status) + tomogram_names = fieldnames(merged_configuration.tomograms); + if isfield(merged_configuration, "tomogram_interval") && ~isempty(merged_configuration.tomogram_interval) + tomogram_names = {tomogram_names{1:length(previous_tomogram_status)}}; + elseif isfield(merged_configuration, "tomogram_start") && isfield(merged_configuration, "tomogram_end") && merged_configuration.tomogram_start ~= -1 && merged_configuration.tomogram_end ~= -1 + tomogram_names = {tomogram_names{merged_configuration.tomogram_start:merged_configuration.tomogram_step:merged_configuration.tomogram_end}}; + end + end + + function [dynamic_configuration_out, status] = execution_sequential(obj, merged_configuration, pipeline_definition, previous_tomogram_status) + tomogram_names = obj.setUpInterval(merged_configuration, previous_tomogram_status); + status = cell([1 length(previous_tomogram_status)]); + dynamic_configurations = cell([1 length(previous_tomogram_status)]); + + for j = 1:length(previous_tomogram_status) + status{j} = 0; + dynamic_configurations{j} = struct; + end + + for j = find(previous_tomogram_status) + disp("INFO: Executing pipeline step " + num2str(merged_configuration.set_up.i - 1) + ... + ": " + pipeline_definition + " for tomogram " + j + "..."); + merged_configuration = obj.fillSetUpStructIteration(merged_configuration, j, previous_tomogram_status); + [dynamic_configurations{j}, status{j}] = iteration(merged_configuration, pipeline_definition, tomogram_names{j}, previous_tomogram_status(j)); + disp("INFO: Execution of pipeline step " + num2str(merged_configuration.set_up.i - 1) + ... + " (" + pipeline_definition + ") for tomogram " + j + " has finished!"); + end + + dynamic_configuration_out = obj.combineConfigurations(dynamic_configurations); + status = [status{:}]; + end + + function configurations = readConfigurationsFromFolder(obj, folder) + configurations = readConfigurationsFromFolder(folder); + end + + function configuration = loadJSON(obj, file_path) + configuration = loadJSON(file_path); + end + + function combined_configuration = readAndCombineConfigurationsFromFolder(obj, folder) + configurations = obj.readConfigurationsFromFolder(folder); + combined_configuration = obj.combineConfigurations(configurations); + end + + function [first_configuration_out, second_configuration_out] = combineConfigurations(obj, first_configurations_in, second_configurations_in) + if nargin == 2 + first_configuration_out = combineConfigurations(first_configurations_in); + elseif nargin == 3 + [first_configuration_out, second_configuration_out] = combineConfigurations(first_configurations_in, second_configurations_in); + end + end + + function dynamic_configuration_out = finishPipelineStep(obj, ... + dynamic_configuration_in, pipeline_definition, ... + configuration_history, i) + % TODO: merge only dynamic_configuration in, first it + % needs to be stored or is it already stored? seems so... + if ~isfield(configuration_history, pipeline_definition) + disp("INFO: No history available for step " + num2str(i - 1) + ... + " (" + pipeline_definition + ")!") + dynamic_configuration_temporary = struct(); + else + dynamic_configuration_temporary = configuration_history.(pipeline_definition); + end + disp("INFO: Skipping processing step " + num2str(i - 1) + ... + " (" + pipeline_definition + ")!"); + % NOTE: downstreams all properties of every + % dynamic_configuration_temporary and possibly overwrites + % with new values + if ~isempty(fieldnames(dynamic_configuration_temporary)) + dynamic_configuration_out = obj.mergeConfigurations(dynamic_configuration_in, dynamic_configuration_temporary, 0, "dynamic"); + else + dynamic_configuration_out = dynamic_configuration_temporary; + end + end + + function createOutputAndScratchFoldersForPipelineStep(obj, merged_configuration) + createOutputAndScratchFoldersForPipelineStep(merged_configuration); + end + + function parforSave(obj, path, variable) + parforSave(obj.semaphore_key, path, variable) + end + + function saveJSON(obj, path, variable) + saveJSON(path, variable); + end + + function configuration = fillSetUpStructPipelineStep(obj, configuration, i) + configuration = fillSetUpStructPipelineStep(configuration, i); + end + + function configuration = fillSetUpStructIteration(obj, configuration, j, previous_tomogram_status) + configuration = fillSetUpStructIteration(configuration, j, previous_tomogram_status); + end + end +end diff --git a/pipeline/LocalPipeline.m b/pipeline/LocalPipeline.m old mode 100755 new mode 100644 index b7090c2..5a150d8 --- a/pipeline/LocalPipeline.m +++ b/pipeline/LocalPipeline.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef LocalPipeline < Pipeline methods function obj = LocalPipeline(configuration_path, default_configuration_path) @@ -588,7 +607,7 @@ function execute(obj, tomogram_begin, tomogram_end, pipeline_ending_step, gpu) [status_mkdir, message, message_id] = mkdir(pool_folder); end - generatePool(workers, false, pool_folder); + poolobj = generatePool(workers, false, pool_folder); cumulative_sum_previous_tomogram_status = cumsum(previous_tomogram_status); indices = find(previous_tomogram_status); @@ -609,7 +628,7 @@ function execute(obj, tomogram_begin, tomogram_end, pipeline_ending_step, gpu) % TODO intermediate configurations need to be saved to be % consistent f(mod(j - 1, workers) + 1) = ... - parfeval(@iteration, 2, merged_configurations{j}, pipeline_definition, tomogram_names{indices(j)}, previous_tomogram_status(indices(j))); + parfeval(poolobj, @iteration, 2, merged_configurations{j}, pipeline_definition, tomogram_names{indices(j)}, previous_tomogram_status(indices(j))); end if exist("f", "var") && ~isempty(f) diff --git a/pipeline/Pipeline.m b/pipeline/Pipeline.m old mode 100755 new mode 100644 index 304af89..357a275 --- a/pipeline/Pipeline.m +++ b/pipeline/Pipeline.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef Pipeline < handle properties diff --git a/pipeline/SlurmPipeline.m b/pipeline/SlurmPipeline.m old mode 100755 new mode 100644 index 6e78f67..b251e30 --- a/pipeline/SlurmPipeline.m +++ b/pipeline/SlurmPipeline.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + classdef SlurmPipeline < Pipeline methods function obj = SlurmPipeline(configuration_path, default_configuration_path) diff --git a/pipeline/runPipeline.m b/pipeline/runPipeline.m old mode 100755 new mode 100644 index 0ac4e84..a9db0c2 --- a/pipeline/runPipeline.m +++ b/pipeline/runPipeline.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function runPipeline(compute_environment, configuration_path, default_configuration_path, starting_tomogram, ending_tomogram, step, gpu) if nargin <= 3 starting_tomogram = -1; @@ -72,6 +91,30 @@ function runPipeline(compute_environment, configuration_path, default_configurat else disp("WARNING: TomoBEAR is only partly initialized!"); end +elseif string(compute_environment) == "local_live" + %% PIPELINE GENERATION + if nargin == 1 + pipeline = LocalLivePipeline("meta_data/project.json"); + elseif nargin == 2 && ~exist("default_configuration_path", "var") + pipeline = LocalLivePipeline(configuration_path); + elseif nargin >= 3 || nargin == 2 && exist("default_configuration_path", "var") + pipeline = LocalLivePipeline(configuration_path, default_configuration_path); + end + + %% PRINT GENERATED PIPELINE + pipeline.print(); + + %% PIPELINE EXECUTION + if nargin <= 3 + pipeline.execute() + else + if isdeployed() == true + pipeline.execute(str2double(starting_tomogram), str2double(ending_tomogram), str2double(step), str2double(gpu)); + else + pipeline.execute(starting_tomogram, ending_tomogram, step, gpu); + end + end + elseif string(compute_environment) == "local" %if isdeployed() % TODO: think of passing project_path to initializeEnvironment diff --git a/pipeline/runTomoBEAR.m b/pipeline/runTomoBEAR.m index 4f0b5e7..381fd7d 100644 --- a/pipeline/runTomoBEAR.m +++ b/pipeline/runTomoBEAR.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function runTomoBEAR(compute_environment, configuration_path, default_configuration_path, starting_tomogram, ending_tomogram, step, gpu) if nargin <= 2 if fileExists("CONFIGURATION") diff --git a/pipeline/runTomoBear.m b/pipeline/runTomoBear.m index da5f19e..85691ba 100644 --- a/pipeline/runTomoBear.m +++ b/pipeline/runTomoBear.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function runTomoBear(compute_environment, configuration_path, default_configuration_path, starting_tomogram, ending_tomogram, step, gpu) if nargin <= 2 if fileExists("CONFIGURATION") diff --git a/startup.m b/startup.m index e788fca..cf63205 100755 --- a/startup.m +++ b/startup.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % TODO: decide what to do with userpath %userpath("clear"); %userpath(project_path); @@ -31,7 +50,7 @@ system("chmod ug+x ./load_modules.sh"); end end - + if ~fileExists(default_configuration.general.matlab_shell) || default_configuration.general.regenerate_load_modules_file == true fid = fopen(default_configuration.general.matlab_shell, "w+"); fprintf(fid, "%s\n", "#!/bin/bash"); @@ -41,7 +60,7 @@ if fileExists("./load_modules.sh") fprintf(fid, "%s\n", "source $SCRIPTPATH/load_modules.sh > /dev/null"); end - + if default_configuration.general.additional_shell_initialization_script ~= "" fprintf(fid, "%s\n", "source " + default_configuration.general.additional_shell_initialization_script); end @@ -71,8 +90,8 @@ setenv("MATLAB_SHELL", project_path + string(filesep) + default_configuration.general.matlab_shell); [status, output] = system("chmod ug+x " + default_configuration.general.matlab_shell); else - - end + + end end if ~isdeployed() @@ -87,4 +106,4 @@ if ~isdeployed() dbstop if error; dbstop if warning; -end \ No newline at end of file +end diff --git a/utilities/addFileSeparator.m b/utilities/addFileSeparator.m old mode 100755 new mode 100644 index 568f825..8b2148c --- a/utilities/addFileSeparator.m +++ b/utilities/addFileSeparator.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function path = addFileSeparator(path) if path == "" return; diff --git a/utilities/checkForMultipleExtensions.m b/utilities/checkForMultipleExtensions.m old mode 100755 new mode 100644 index 11ee45e..78b8ca6 --- a/utilities/checkForMultipleExtensions.m +++ b/utilities/checkForMultipleExtensions.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function multiple_extensions = checkForMultipleExtensions(files) for i = 1:length(files) [~, ~, extension{i}] = fileparts(files{i}); diff --git a/utilities/cleanCroppedParticlesTable.m b/utilities/cleanCroppedParticlesTable.m index 206e7ff..89d0f74 100644 --- a/utilities/cleanCroppedParticlesTable.m +++ b/utilities/cleanCroppedParticlesTable.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function table = cleanCroppedParticlesTable(table, particles_path, as_boxes) % Removes particles from the table which where not cropped (e.g. were % discarded due to exceeding tomogram borders) diff --git a/utilities/combineCCVolumes.m b/utilities/combineCCVolumes.m old mode 100755 new mode 100644 index 210f509..d08ff5f --- a/utilities/combineCCVolumes.m +++ b/utilities/combineCCVolumes.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [combined_volume, combined_tdrot, combined_tilt, combined_narot] = combineCCVolumes(template_matching_path) dir_list = dir(template_matching_path + "*angle*"); for i = 1:length(dir_list) diff --git a/utilities/combineConfigurations.m b/utilities/combineConfigurations.m old mode 100755 new mode 100644 index 320cce2..b899d95 --- a/utilities/combineConfigurations.m +++ b/utilities/combineConfigurations.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [first_configuration_out, second_configuration_out] = combineConfigurations(first_configurations_in, second_configurations_in) if length(first_configurations_in) > 1 for j = 1:length(first_configurations_in) - 1 diff --git a/utilities/compileTomoBEAR.m b/utilities/compileTomoBEAR.m old mode 100755 new mode 100644 index 5a2ce17..2c96983 --- a/utilities/compileTomoBEAR.m +++ b/utilities/compileTomoBEAR.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function results = compileTomoBEAR(build_destination, default_configuration_path) % TODO: automate compilation %https://www.mathworks.com/help/compiler/compiler.runtime.download.html diff --git a/utilities/copyOrLinkFilesBasedOnSizeThreshold.m b/utilities/copyOrLinkFilesBasedOnSizeThreshold.m old mode 100755 new mode 100644 index b239175..3478750 --- a/utilities/copyOrLinkFilesBasedOnSizeThreshold.m +++ b/utilities/copyOrLinkFilesBasedOnSizeThreshold.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function copyOrLinkFilesBasedOnSizeThreshold(source, destination, threshold, log_file_id) file_list = dir(source); file_list(1) = []; diff --git a/utilities/createDynamoLinks.m b/utilities/createDynamoLinks.m old mode 100755 new mode 100644 index a76e082..379fd89 --- a/utilities/createDynamoLinks.m +++ b/utilities/createDynamoLinks.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function createDynamoLinks(dynamo_path, link_destination_path) if nargin == 0 error("ERROR: please provide path to dynamo") diff --git a/utilities/createOutputAndScratchFoldersForPipelineStep.m b/utilities/createOutputAndScratchFoldersForPipelineStep.m old mode 100755 new mode 100644 index 5dc875f..573179f --- a/utilities/createOutputAndScratchFoldersForPipelineStep.m +++ b/utilities/createOutputAndScratchFoldersForPipelineStep.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function createOutputAndScratchFoldersForPipelineStep(merged_configuration) % TODO: check status if exist(merged_configuration.output_path, "dir")... diff --git a/utilities/createStandardFolder.m b/utilities/createStandardFolder.m old mode 100755 new mode 100644 index a739030..95aeaf6 --- a/utilities/createStandardFolder.m +++ b/utilities/createStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function folder = createStandardFolder(configuration, standard_folder, delete) if isfield(configuration, standard_folder) if nargin == 2 diff --git a/utilities/createSymbolicLink.m b/utilities/createSymbolicLink.m old mode 100755 new mode 100644 index 844064e..3ffd4f5 --- a/utilities/createSymbolicLink.m +++ b/utilities/createSymbolicLink.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [destination, output] = createSymbolicLink(source, destination, log_file_id, relative) if nargin == 2 || nargin == 3 relative = true; diff --git a/utilities/createSymbolicLinkInStandardFolder.m b/utilities/createSymbolicLinkInStandardFolder.m old mode 100755 new mode 100644 index fd68d55..e008539 --- a/utilities/createSymbolicLinkInStandardFolder.m +++ b/utilities/createSymbolicLinkInStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [output, destination] = createSymbolicLinkInStandardFolder(configuration, source, standard_folder, log_file_id, execute) if nargin <= 4 execute = true; diff --git a/utilities/executeCommand.m b/utilities/executeCommand.m old mode 100755 new mode 100644 index 16c4f24..38894e3 --- a/utilities/executeCommand.m +++ b/utilities/executeCommand.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function output = executeCommand(command, ignore_errors, log_file_id, hide_output) if nargin < 4 hide_output = false; diff --git a/utilities/fileExists.m b/utilities/fileExists.m old mode 100755 new mode 100644 index 5dc562e..da4ff3d --- a/utilities/fileExists.m +++ b/utilities/fileExists.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function exists = fileExists(fileName) if isfile(fileName) exists = true; diff --git a/utilities/fillSetUpStructIteration.m b/utilities/fillSetUpStructIteration.m old mode 100755 new mode 100644 index 873ef19..d4e6ca4 --- a/utilities/fillSetUpStructIteration.m +++ b/utilities/fillSetUpStructIteration.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function configuration = fillSetUpStructIteration(configuration, j, previous_tomogram_status) configuration.set_up.j = j; configuration.set_up.cumulative_tomogram_status = cumsum(previous_tomogram_status); diff --git a/utilities/fillSetUpStructPipelineStep.m b/utilities/fillSetUpStructPipelineStep.m old mode 100755 new mode 100644 index b19a16b..fbe7851 --- a/utilities/fillSetUpStructPipelineStep.m +++ b/utilities/fillSetUpStructPipelineStep.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function configuration = fillSetUpStructPipelineStep(configuration, i) configuration.set_up = struct; configuration.set_up.i = i; diff --git a/utilities/finishPipelineStep.m b/utilities/finishPipelineStep.m old mode 100755 new mode 100644 index f77296e..e85bd30 --- a/utilities/finishPipelineStep.m +++ b/utilities/finishPipelineStep.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function dynamic_configuration = finishPipelineStep(... dynamic_configuration, pipeline_definition,... configuration_history, i) diff --git a/utilities/generateMaskFromTemplate.m b/utilities/generateMaskFromTemplate.m index ed974b7..6f9b18b 100644 --- a/utilities/generateMaskFromTemplate.m +++ b/utilities/generateMaskFromTemplate.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function mask_binarized_smoothed_cleaned = generateMaskFromTemplate(configuration, template) mask = dbandpass(-template, configuration.mask_bandpass); mask_binarized = gather(imbinarize(mask)); diff --git a/utilities/generateParticles.m b/utilities/generateParticles.m old mode 100755 new mode 100644 index 23e6c57..c811680 --- a/utilities/generateParticles.m +++ b/utilities/generateParticles.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function particles_path = generateParticles(configuration, table_path, binning, box_size, append_tags, force_method) if nargin < 6 @@ -116,6 +135,11 @@ if binning > 1 aligned_tilt_stacks = getBinnedAlignedTiltStacksFromStandardFolder(configuration, true, binning); + aligned_tilt_stacks = aligned_tilt_stacks(contains({aligned_tilt_stacks.name}, "bin_" + binning)); + if isempty(aligned_tilt_stacks) == true + error("ERROR: No binned aligned non-CTF-corrected stacks at the requested binning level bin_" + binning); + %aligned_tilt_stacks = getCtfCorrectedBinnedAlignedTiltStacksFromStandardFolder(configuration, true); + end else aligned_tilt_stacks_raw = getAlignedTiltStacksFromStandardFolder(configuration, true); @@ -138,8 +162,9 @@ %tlt_files = getFilesFromLastModuleRun(obj.configuration, "BatchRunTomo", "tlt", "last"); tlt_files = getFilesWithMatchingPatternFromLastBatchruntomoRun(configuration, ".tlt"); -%defocus_files = getFilesFromLastModuleRun(obj.configuration, "BatchRunTomo", "defocus", "last"); -defocus_files = getFilesWithMatchingPatternFromLastBatchruntomoRun(configuration, ".defocus"); +%defocus_files = getFilesFromLastModuleRun(configuration, "GCTFCtfphaseflipCTFCorrection", "defocus", "last"); +%defocus_files = getFilesWithMatchingPatternFromLastBatchruntomoRun(configuration, ".defocus"); +defocus_files = getDefocusFiles(configuration, ".defocus"); tomos_id = unique(table(:,20)); diff --git a/utilities/generatePool.m b/utilities/generatePool.m index f32e289..c23e859 100644 --- a/utilities/generatePool.m +++ b/utilities/generatePool.m @@ -1,4 +1,23 @@ -function generatePool(cores, force, path, debug) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function poolobj = generatePool(cores, force, path, debug) persistent previous_cores; if isempty(previous_cores) previous_cores = 0; @@ -10,7 +29,7 @@ function generatePool(cores, force, path, debug) pc.JobStorageLocation = char(path); end -if force || previous_cores == 0 || previous_cores ~= cores +if force || previous_cores == 0 || previous_cores ~= cores || isempty(poolobj) poolsize = getCpuPoolSize(cores); diff --git a/utilities/generateSetUpStruct.m b/utilities/generateSetUpStruct.m old mode 100755 new mode 100644 index eb13017..59afe17 --- a/utilities/generateSetUpStruct.m +++ b/utilities/generateSetUpStruct.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function configuration = generateSetUpStruct(configuration, previous_tomogram_status, i ,j) configuration.set_up = struct; configuration.set_up.i = i; diff --git a/utilities/getAlignedEvenTiltStacksFromStandardFolder.m b/utilities/getAlignedEvenTiltStacksFromStandardFolder.m index 9a78b69..4f48109 100644 --- a/utilities/getAlignedEvenTiltStacksFromStandardFolder.m +++ b/utilities/getAlignedEvenTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getAlignedEvenTiltStacksFromStandardFolder(configuration, flatten) if nargin <= 1 diff --git a/utilities/getAlignedOddTiltStacksFromStandardFolder.m b/utilities/getAlignedOddTiltStacksFromStandardFolder.m index a86ac80..05c5b67 100644 --- a/utilities/getAlignedOddTiltStacksFromStandardFolder.m +++ b/utilities/getAlignedOddTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getAlignedOddTiltStacksFromStandardFolder(configuration, flatten) if nargin <= 1 diff --git a/utilities/getAlignedTiltStacksFromStandardFolder.m b/utilities/getAlignedTiltStacksFromStandardFolder.m old mode 100755 new mode 100644 index f2522b6..8d3ec80 --- a/utilities/getAlignedTiltStacksFromStandardFolder.m +++ b/utilities/getAlignedTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getAlignedTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getApix.m b/utilities/getApix.m index 1cf8bde..57da5ab 100644 --- a/utilities/getApix.m +++ b/utilities/getApix.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [rescaled_pixelsize, apix] = getApix(configuration, scaling_binning_factor) if nargin == 1 scaling_binning_factor = 1; diff --git a/utilities/getBinnedAlignedEvenTiltStacksFromStandardFolder.m b/utilities/getBinnedAlignedEvenTiltStacksFromStandardFolder.m index 2c30744..8da9bcc 100644 --- a/utilities/getBinnedAlignedEvenTiltStacksFromStandardFolder.m +++ b/utilities/getBinnedAlignedEvenTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getBinnedAlignedEvenTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getBinnedAlignedOddTiltStacksFromStandardFolder.m b/utilities/getBinnedAlignedOddTiltStacksFromStandardFolder.m index 88707c4..3c24aa6 100644 --- a/utilities/getBinnedAlignedOddTiltStacksFromStandardFolder.m +++ b/utilities/getBinnedAlignedOddTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getBinnedAlignedOddTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getBinnedAlignedTiltStacksFromStandardFolder.m b/utilities/getBinnedAlignedTiltStacksFromStandardFolder.m old mode 100755 new mode 100644 index ebbe969..a5a4a84 --- a/utilities/getBinnedAlignedTiltStacksFromStandardFolder.m +++ b/utilities/getBinnedAlignedTiltStacksFromStandardFolder.m @@ -1,19 +1,40 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getBinnedAlignedTiltStacksFromStandardFolder(configuration, flatten, binning) if nargin <= 2 - binning = ""; + binning_snippet = "*"; +else + binning_snippet = "*bin_" + binning; end if nargin <= 1 flatten = false; end -if isfield(configuration, "aligned_tilt_stacks_folder") && flatten == true +if isfield(configuration, "binned_aligned_tilt_stacks_folder") && flatten == true tilt_stack_path = configuration.processing_path + string(filesep)... + configuration.output_folder + string(filesep)... + configuration.binned_aligned_tilt_stacks_folder + string(filesep)... - + "**" + string(filesep) + "*bin_" + binning + ".ali"; + + "**" + string(filesep) + binning_snippet + ".ali"; tilt_stacks = dir(tilt_stack_path); -elseif isfield(configuration, "aligned_tilt_stacks_folder") && flatten == false +elseif isfield(configuration, "binned_aligned_tilt_stacks_folder") && flatten == false tilt_stack_path = configuration.processing_path + string(filesep)... + configuration.output_folder + string(filesep)... + configuration.binned_aligned_tilt_stacks_folder; @@ -25,7 +46,7 @@ && (tilt_stacks_folders(i).name ~= "." && tilt_stacks_folders(i).name ~= "..") tilt_stacks{counter} = dir(tilt_stacks_folders(i).folder... + string(filesep) + tilt_stacks_folders(i).name... - + string(filesep) + "*bin_" + binning + ".ali"); + + string(filesep) + binning_snippet + ".ali"); counter = counter + 1; end end diff --git a/utilities/getBinnedEvenTiltStacksFromStandardFolder.m b/utilities/getBinnedEvenTiltStacksFromStandardFolder.m index d5cc994..d2a313c 100644 --- a/utilities/getBinnedEvenTiltStacksFromStandardFolder.m +++ b/utilities/getBinnedEvenTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getBinnedEvenTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getBinnedOddTiltStacksFromStandardFolder.m b/utilities/getBinnedOddTiltStacksFromStandardFolder.m index 752ddbe..0629e1b 100644 --- a/utilities/getBinnedOddTiltStacksFromStandardFolder.m +++ b/utilities/getBinnedOddTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getBinnedOddTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getBinnedTiltStacksFromStandardFolder.m b/utilities/getBinnedTiltStacksFromStandardFolder.m new file mode 100644 index 0000000..577a2fe --- /dev/null +++ b/utilities/getBinnedTiltStacksFromStandardFolder.m @@ -0,0 +1,53 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function tilt_stacks = getBinnedTiltStacksFromStandardFolder(configuration, flatten) +if nargin == 1 + flatten = false; +end + +if isfield(configuration, "binned_tilt_stacks_folder") && flatten == true + tilt_stack_path = configuration.processing_path + string(filesep)... + + configuration.output_folder + string(filesep)... + + configuration.binned_tilt_stacks_folder... + + string(filesep) + "**" + string(filesep) + "*.st"; + tilt_stacks = dir(tilt_stack_path); +elseif isfield(configuration, "binned_tilt_stacks_folder") && flatten == false + tilt_stack_path = configuration.processing_path + string(filesep)... + + configuration.output_folder + string(filesep)... + + configuration.binned_tilt_stacks_folder; + tilt_stacks_folders = dir(tilt_stack_path); + tilt_stacks = {}; + counter = 1; + for i = 1:length(tilt_stacks_folders) + if tilt_stacks_folders(i).isdir... + && (tilt_stacks_folders(i).name ~= "."... + && tilt_stacks_folders(i).name ~= "..") + tilt_stacks{counter} = dir(tilt_stacks_folders(i).folder... + + string(filesep) + tilt_stacks_folders(i).name... + + string(filesep) + "*.st"); + counter = counter + 1; + end + end +end + +if isempty(tilt_stacks) + disp("INFO: No binned tilt stacks found at standard location " + tilt_stack_path); +end +end diff --git a/utilities/getBinnedTomogramsFromStandardFolder.m b/utilities/getBinnedTomogramsFromStandardFolder.m old mode 100755 new mode 100644 index 5a32b53..93f7deb --- a/utilities/getBinnedTomogramsFromStandardFolder.m +++ b/utilities/getBinnedTomogramsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function binned_tomograms = getBinnedTomogramsFromStandardFolder(configuration, flatten, binning) if nargin == 1 flatten = false; diff --git a/utilities/getCpuPoolSize.m b/utilities/getCpuPoolSize.m index 9f9c4a4..2e2b9bd 100644 --- a/utilities/getCpuPoolSize.m +++ b/utilities/getCpuPoolSize.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function poolsize = getCpuPoolSize(cores, cores_requested) % get number of cores available on the used machine diff --git a/utilities/getCtfCorrectedAlignedTiltStacksFromStandardFolder.m b/utilities/getCtfCorrectedAlignedTiltStacksFromStandardFolder.m old mode 100755 new mode 100644 index 7338cab..1f049d7 --- a/utilities/getCtfCorrectedAlignedTiltStacksFromStandardFolder.m +++ b/utilities/getCtfCorrectedAlignedTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getCtfCorrectedAlignedTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getCtfCorrectedBinnedAlignedEvenTiltStacksFromStandardFolder.m b/utilities/getCtfCorrectedBinnedAlignedEvenTiltStacksFromStandardFolder.m index 2f95198..f04c930 100644 --- a/utilities/getCtfCorrectedBinnedAlignedEvenTiltStacksFromStandardFolder.m +++ b/utilities/getCtfCorrectedBinnedAlignedEvenTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getCtfCorrectedBinnedAlignedEvenTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getCtfCorrectedBinnedAlignedOddTiltStacksFromStandardFolder.m b/utilities/getCtfCorrectedBinnedAlignedOddTiltStacksFromStandardFolder.m index c6b2c59..9faf172 100644 --- a/utilities/getCtfCorrectedBinnedAlignedOddTiltStacksFromStandardFolder.m +++ b/utilities/getCtfCorrectedBinnedAlignedOddTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getCtfCorrectedBinnedAlignedOddTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getCtfCorrectedBinnedAlignedTiltStacksFromStandardFolder.m b/utilities/getCtfCorrectedBinnedAlignedTiltStacksFromStandardFolder.m old mode 100755 new mode 100644 index d176d2d..4286259 --- a/utilities/getCtfCorrectedBinnedAlignedTiltStacksFromStandardFolder.m +++ b/utilities/getCtfCorrectedBinnedAlignedTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getCtfCorrectedBinnedAlignedTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getCtfCorrectedBinnedEvenTiltStacksFromStandardFolder.m b/utilities/getCtfCorrectedBinnedEvenTiltStacksFromStandardFolder.m index ffdfb56..244e868 100644 --- a/utilities/getCtfCorrectedBinnedEvenTiltStacksFromStandardFolder.m +++ b/utilities/getCtfCorrectedBinnedEvenTiltStacksFromStandardFolder.m @@ -1,2 +1,21 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function getCtfCorrectedBinnedEvenTiltStacksFromStandardFolder() end diff --git a/utilities/getCtfCorrectedBinnedEvenTomogramsFromStandardFolder.m b/utilities/getCtfCorrectedBinnedEvenTomogramsFromStandardFolder.m index b24e6e9..d32dc1a 100644 --- a/utilities/getCtfCorrectedBinnedEvenTomogramsFromStandardFolder.m +++ b/utilities/getCtfCorrectedBinnedEvenTomogramsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function binned_tomograms = getCtfCorrectedBinnedEvenTomogramsFromStandardFolder(configuration, flatten, binning) if nargin == 1 flatten = false; diff --git a/utilities/getCtfCorrectedBinnedOddTiltStacksFromStandardFolder.m b/utilities/getCtfCorrectedBinnedOddTiltStacksFromStandardFolder.m index 61459a3..b926bcb 100644 --- a/utilities/getCtfCorrectedBinnedOddTiltStacksFromStandardFolder.m +++ b/utilities/getCtfCorrectedBinnedOddTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function getCtfCorrectedBinnedOddTiltStacksFromStandardFolder() end diff --git a/utilities/getCtfCorrectedBinnedOddTomogramsFromStandardFolder.m b/utilities/getCtfCorrectedBinnedOddTomogramsFromStandardFolder.m index 3b3d9b1..f2304ac 100644 --- a/utilities/getCtfCorrectedBinnedOddTomogramsFromStandardFolder.m +++ b/utilities/getCtfCorrectedBinnedOddTomogramsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function binned_tomograms = getCtfCorrectedBinnedOddTomogramsFromStandardFolder(configuration, flatten, binning) if nargin == 1 flatten = false; diff --git a/utilities/getCtfCorrectedBinnedTomogramsFromStandardFolder.m b/utilities/getCtfCorrectedBinnedTomogramsFromStandardFolder.m old mode 100755 new mode 100644 index 62aa50b..798fbde --- a/utilities/getCtfCorrectedBinnedTomogramsFromStandardFolder.m +++ b/utilities/getCtfCorrectedBinnedTomogramsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function binned_tomograms = getCtfCorrectedBinnedTomogramsFromStandardFolder(configuration, flatten, binning) if nargin == 1 flatten = false; diff --git a/utilities/getCtfCorrectedTomogramsFromStandardFolder.m b/utilities/getCtfCorrectedTomogramsFromStandardFolder.m old mode 100755 new mode 100644 index ff4c285..4bc82d8 --- a/utilities/getCtfCorrectedTomogramsFromStandardFolder.m +++ b/utilities/getCtfCorrectedTomogramsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tomograms = getCtfCorrectedTomogramsFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getDefocusFiles.m b/utilities/getDefocusFiles.m new file mode 100644 index 0000000..57b05d1 --- /dev/null +++ b/utilities/getDefocusFiles.m @@ -0,0 +1,31 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function file_paths = getDefocusFiles(configuration, pattern) +% TODO: check for "." in pattern +original_mrcs = fieldnames(configuration.tomograms); +ctf_folder_dir = dir(configuration.processing_path + string(filesep)... + + configuration.output_folder + string(filesep) + "*_GCTFCtfphaseflipCTFCorrection_*"); +ctf_folder_path = ctf_folder_dir(1).folder + string(filesep) + ctf_folder_dir(1).name; +for i = 1:length(original_mrcs) + [path, name, extension] = fileparts(original_mrcs{i}); + file_paths{i} = dir(ctf_folder_path + string(filesep) + name + string(filesep) + "*" + pattern); +end +end + diff --git a/utilities/getDenoisedCtfCorrectedBinnedTomogramsFromStandardFolder.m b/utilities/getDenoisedCtfCorrectedBinnedTomogramsFromStandardFolder.m index 6afb98e..b7ebf54 100644 --- a/utilities/getDenoisedCtfCorrectedBinnedTomogramsFromStandardFolder.m +++ b/utilities/getDenoisedCtfCorrectedBinnedTomogramsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function binned_tomograms = getDenoisedCtfCorrectedBinnedTomogramsFromStandardFolder(configuration, flatten, binning) if nargin == 1 flatten = false; diff --git a/utilities/getDenoisedCtfCorrectedTomogramsFromStandardFolder.m b/utilities/getDenoisedCtfCorrectedTomogramsFromStandardFolder.m index 0974b5e..6fa855a 100644 --- a/utilities/getDenoisedCtfCorrectedTomogramsFromStandardFolder.m +++ b/utilities/getDenoisedCtfCorrectedTomogramsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function binned_tomograms = getDenoisedCtfCorrectedBinnedTomogramsFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getDoseWeightedSumTiltStacksFromStandardFolder.m b/utilities/getDoseWeightedSumTiltStacksFromStandardFolder.m new file mode 100644 index 0000000..2307910 --- /dev/null +++ b/utilities/getDoseWeightedSumTiltStacksFromStandardFolder.m @@ -0,0 +1,53 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function tilt_stacks = getDoseWeightedSumTiltStacksFromStandardFolder(configuration, flatten) +if nargin == 1 + flatten = false; +end + +if isfield(configuration, "dose_weighted_sum_tilt_stacks_folder") && flatten == true + tilt_stack_path = configuration.processing_path + string(filesep)... + + configuration.output_folder + string(filesep)... + + configuration.dose_weighted_sum_tilt_stacks_folder... + + string(filesep) + "**" + string(filesep) + "*.st"; + tilt_stacks = dir(tilt_stack_path); +elseif isfield(configuration, "dose_weighted_sum_tilt_stacks_folder") && flatten == false + tilt_stack_path = configuration.processing_path + string(filesep)... + + configuration.output_folder + string(filesep)... + + configuration.dose_weighted_sum_tilt_stacks_folder; + tilt_stacks_folders = dir(tilt_stack_path); + tilt_stacks = {}; + counter = 1; + for i = 1:length(tilt_stacks_folders) + if tilt_stacks_folders(i).isdir... + && (tilt_stacks_folders(i).name ~= "."... + && tilt_stacks_folders(i).name ~= "..") + tilt_stacks{counter} = dir(tilt_stacks_folders(i).folder... + + string(filesep) + tilt_stacks_folders(i).name... + + string(filesep) + "*.st"); + counter = counter + 1; + end + end +end + +if isempty(tilt_stacks) + disp("INFO: No dose_weighted sum tilt stacks found at standard location " + tilt_stack_path); +end +end diff --git a/utilities/getDoseWeightedTiltStacksFromStandardFolder.m b/utilities/getDoseWeightedTiltStacksFromStandardFolder.m index 63b1ed4..24ccdb0 100644 --- a/utilities/getDoseWeightedTiltStacksFromStandardFolder.m +++ b/utilities/getDoseWeightedTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getDoseWeightedTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getDynamoFiles.m b/utilities/getDynamoFiles.m old mode 100755 new mode 100644 index c147958..3fbae93 --- a/utilities/getDynamoFiles.m +++ b/utilities/getDynamoFiles.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function dynamo_files = getDynamoFiles(prefix) if nargin == 0 prefix = ""; diff --git a/utilities/getEnvironmentProperties.m b/utilities/getEnvironmentProperties.m old mode 100755 new mode 100644 index fdb8d2b..aa34a85 --- a/utilities/getEnvironmentProperties.m +++ b/utilities/getEnvironmentProperties.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function environment_properties = getEnvironmentProperties(configuration) path_to_script = mfilename("fullpath"); path_to_script_split = strsplit(path_to_script, string(filesep)); diff --git a/utilities/getEvenTiltStacksFromStandardFolder.m b/utilities/getEvenTiltStacksFromStandardFolder.m index d72b0c8..c16e4bb 100644 --- a/utilities/getEvenTiltStacksFromStandardFolder.m +++ b/utilities/getEvenTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getEvenTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getFidFilePaths.m b/utilities/getFidFilePaths.m old mode 100755 new mode 100644 index 1fbd20b..aa209ac --- a/utilities/getFidFilePaths.m +++ b/utilities/getFidFilePaths.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function fiducial_file_paths = getFidFilePaths(configuration) original_mrcs = getOriginalMRCsFromStandardFolder(configuration); batchruntomo_folders = dir(configuration.processing_path + string(filesep)... diff --git a/utilities/getFileCountChanged.m b/utilities/getFileCountChanged.m old mode 100755 new mode 100644 index c0349b0..caac2a4 --- a/utilities/getFileCountChanged.m +++ b/utilities/getFileCountChanged.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function file_count_changed = getFileCountChanged(configuration) [file_list, ~] = getOriginalMRCsorTIFs(configuration); if ~isfield(configuration, "file_count")... diff --git a/utilities/getFilePathsFromLastBatchruntomoRun.m b/utilities/getFilePathsFromLastBatchruntomoRun.m old mode 100755 new mode 100644 index 16be637..b655cfc --- a/utilities/getFilePathsFromLastBatchruntomoRun.m +++ b/utilities/getFilePathsFromLastBatchruntomoRun.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function file_paths = getFilePathsFromLastBatchruntomoRun(configuration, file_extension) batchruntomo_folders = dir(configuration.processing_path + string(filesep)... + configuration.output_folder + string(filesep) + "*_BatchRunTomo_*"); diff --git a/utilities/getFilesFromLastModuleRun.m b/utilities/getFilesFromLastModuleRun.m old mode 100755 new mode 100644 index 220d2f0..1572623 --- a/utilities/getFilesFromLastModuleRun.m +++ b/utilities/getFilesFromLastModuleRun.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function file_paths = getFilesFromLastModuleRun(configuration, module_name, file_extension, choice) if nargin == 3 choice = "last"; diff --git a/utilities/getFilesWithMatchingPatternFromLastBatchruntomoRun.m b/utilities/getFilesWithMatchingPatternFromLastBatchruntomoRun.m old mode 100755 new mode 100644 index a516929..14756e0 --- a/utilities/getFilesWithMatchingPatternFromLastBatchruntomoRun.m +++ b/utilities/getFilesWithMatchingPatternFromLastBatchruntomoRun.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function file_paths = getFilesWithMatchingPatternFromLastBatchruntomoRun(configuration, pattern) % TODO: check for "." in pattern original_mrcs = fieldnames(configuration.tomograms); diff --git a/utilities/getHeightAndWidthFromHeader.m b/utilities/getHeightAndWidthFromHeader.m old mode 100755 new mode 100644 index 6366c5e..2e3b479 --- a/utilities/getHeightAndWidthFromHeader.m +++ b/utilities/getHeightAndWidthFromHeader.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [width, height, z] = getHeightAndWidthFromHeader(file_path, log_file_id) if iscell(file_path) command = sprintf("header %s", file_path{1}); diff --git a/utilities/getIMODVersion.m b/utilities/getIMODVersion.m old mode 100755 new mode 100644 index baa4726..6b651d7 --- a/utilities/getIMODVersion.m +++ b/utilities/getIMODVersion.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function imod_version = getIMODVersion() output = executeCommand("3dmod -h", true, -1, true); output_lines = textscan(output,"%s","Delimiter","","endofline","\n"); diff --git a/utilities/getMask.m b/utilities/getMask.m old mode 100755 new mode 100644 index 85a9b9a..4e8a03d --- a/utilities/getMask.m +++ b/utilities/getMask.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function mask = getMask(configuration, path) file_path = configuration.processing_path + string(filesep)... + configuration.output_folder + string(filesep)... diff --git a/utilities/getMetaDataFilePath.m b/utilities/getMetaDataFilePath.m old mode 100755 new mode 100644 index 9667d6a..3e6da62 --- a/utilities/getMetaDataFilePath.m +++ b/utilities/getMetaDataFilePath.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function meta_data_file_path = getMetaDataFilePath(configuration) meta_data_folder_path = getMetaDataFolderPath(configuration); meta_data_file_path = meta_data_folder_path + string(filesep)... diff --git a/utilities/getMetaDataFolderPath.m b/utilities/getMetaDataFolderPath.m old mode 100755 new mode 100644 index 6007ef5..b8a2e58 --- a/utilities/getMetaDataFolderPath.m +++ b/utilities/getMetaDataFolderPath.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function meta_data_folder_path = getMetaDataFolderPath(configuration) meta_data_folder_path = configuration.processing_path + string(filesep) + configuration.output_folder + string(filesep) + configuration.meta_data_folder; end diff --git a/utilities/getMinAndMaxTiltAnglesFromTiltFile.m b/utilities/getMinAndMaxTiltAnglesFromTiltFile.m old mode 100755 new mode 100644 index e35866f..f247800 --- a/utilities/getMinAndMaxTiltAnglesFromTiltFile.m +++ b/utilities/getMinAndMaxTiltAnglesFromTiltFile.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function min_and_max_tilt_angles = getMinAndMaxTiltAnglesFromTiltFile(configuration) tomograms = getTomograms(configuration, true); batchruntomo_folders = dir(configuration.processing_path + string(filesep)... diff --git a/utilities/getMotionCorrectedMRCsFromStandardFolder.m b/utilities/getMotionCorrectedMRCsFromStandardFolder.m old mode 100755 new mode 100644 index 81ea4a2..3e4dfe0 --- a/utilities/getMotionCorrectedMRCsFromStandardFolder.m +++ b/utilities/getMotionCorrectedMRCsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function motion_corrected_mrcs = getMotionCorrectedMRCsFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getOddTiltStacksFromStandardFolder.m b/utilities/getOddTiltStacksFromStandardFolder.m index af6cdc0..c04b303 100644 --- a/utilities/getOddTiltStacksFromStandardFolder.m +++ b/utilities/getOddTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getOddTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getOriginalEERs.m b/utilities/getOriginalEERs.m new file mode 100644 index 0000000..5490195 --- /dev/null +++ b/utilities/getOriginalEERs.m @@ -0,0 +1,65 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function [original_eers, tif_flag] = getOriginalEERs(configuration) +tif_flag = 0; +if isfield(configuration, "tomogram_input_prefix")... + && iscell(configuration.tomogram_input_prefix) + counter = 1; + for i = 1:length(configuration.tomogram_input_prefix) + for j = 1:length(configuration.data_path) + mrc_path(counter) = configuration.data_path{j} + string(filesep)... + + configuration.tomogram_input_prefix{i} + "*.eer"; + counter = counter + 1; + end + end +elseif isfield(configuration, "tomogram_input_prefix")... + && configuration.tomogram_input_prefix ~= "" + mrc_path = configuration.data_path + string(filesep)... + + configuration.tomogram_input_prefix + "*.eer"; +else + mrc_path = configuration.data_path; + if ~contains(mrc_path, ".eer") + mrc_path = mrc_path + string(filesep) + "*.eer"; + end +end + +counter = 1; +for i = 1:length(mrc_path) + original_eers{counter} = dir(mrc_path{i}); + if isempty(original_eers{counter}) + continue; + end + counter = counter + 1; +end + +% if iscell(original_tifs) +% original_files_tmp = struct("name", '', "folder", '', "date", '',... +% "bytes", 0, "isdir", false, "datenum", 0); +% for i = 1:length(original_tifs) +% if i == 1 +% original_files_tmp(1:length(original_tifs{i})) = original_tifs{i}; +% else +% original_files_tmp(end + 1:end + length(original_tifs{i})) = original_tifs{i}; +% end +% end +% original_tifs = original_files_tmp; +% end +end + diff --git a/utilities/getOriginalFiles.m b/utilities/getOriginalFiles.m old mode 100755 new mode 100644 index 5996065..7515b2b --- a/utilities/getOriginalFiles.m +++ b/utilities/getOriginalFiles.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function original_files = getOriginalFiles(configuration, grouped) if nargin == 1 grouped = false; diff --git a/utilities/getOriginalFilesFromFilePaths.m b/utilities/getOriginalFilesFromFilePaths.m old mode 100755 new mode 100644 index 5554681..6b3185f --- a/utilities/getOriginalFilesFromFilePaths.m +++ b/utilities/getOriginalFilesFromFilePaths.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function original_files = getOriginalFilesFromFilePaths(file_paths, grouped) if nargin == 1 grouped = false; diff --git a/utilities/getOriginalMRCs.m b/utilities/getOriginalMRCs.m old mode 100755 new mode 100644 index 2118e6a..ec2472f --- a/utilities/getOriginalMRCs.m +++ b/utilities/getOriginalMRCs.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function original_mrcs = getOriginalMRCs(configuration) if isfield(configuration, "tomogram_input_prefix")... && configuration.tomogram_input_prefix ~= "" diff --git a/utilities/getOriginalMRCsFromStandardFolder.m b/utilities/getOriginalMRCsFromStandardFolder.m old mode 100755 new mode 100644 index e8de104..09029fe --- a/utilities/getOriginalMRCsFromStandardFolder.m +++ b/utilities/getOriginalMRCsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function original_mrcs = getOriginalMRCsFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getOriginalMRCsorTIFs.m b/utilities/getOriginalMRCsorTIFs.m old mode 100755 new mode 100644 index 418985f..63340d7 --- a/utilities/getOriginalMRCsorTIFs.m +++ b/utilities/getOriginalMRCsorTIFs.m @@ -1,5 +1,24 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [original_files, tif_flag] = getOriginalMRCsorTIFs(configuration, grouped) -if nargin == 1 +if nargin < 2 grouped = false; end @@ -17,7 +36,10 @@ mrc_path = configuration.data_path + string(filesep)... + configuration.tomogram_input_prefix + "*.mrc"; else - mrc_path = configuration.data_path + string(filesep) + "*.mrc"; + mrc_path = configuration.data_path; + if ~contains(mrc_path, ".mrc") + mrc_path = mrc_path + string(filesep) + "*.mrc"; + end end counter = 1; @@ -33,11 +55,17 @@ [original_files, tif_flag] = getOriginalTIFs(configuration); end -if isempty(original_files) - error("ERROR: No micrographs found at location " + mrc_path); +if isempty(original_files) || (iscell(original_files) && isempty(original_files{1})) + [original_files, ~] = getOriginalEERs(configuration); end -if iscell(original_files) +if isempty(original_files) || (iscell(original_files) && isempty(original_files{1})) + if ~isfield(configuration, "live_data_mode") || ~configuration.live_data_mode + error("ERROR: No micrographs found at location " + mrc_path); + else + original_files = []; + end +elseif iscell(original_files) original_files_tmp = struct("name", '', "folder", '', "date", '',... "bytes", 0, "isdir", false, "datenum", 0); for i = 1:length(original_files) diff --git a/utilities/getOriginalTIFs.m b/utilities/getOriginalTIFs.m old mode 100755 new mode 100644 index 32d8858..331ec3b --- a/utilities/getOriginalTIFs.m +++ b/utilities/getOriginalTIFs.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [original_tifs, tif_flag] = getOriginalTIFs(configuration) tif_flag = 1; if isfield(configuration, "tomogram_input_prefix")... @@ -15,7 +34,10 @@ mrc_path = configuration.data_path + string(filesep)... + configuration.tomogram_input_prefix + "*.tif"; else - mrc_path = configuration.data_path + string(filesep) + "*.tif"; + mrc_path = configuration.data_path; + if ~contains(mrc_path, ".tif") + mrc_path = mrc_path + string(filesep) + "*.tif"; + end end counter = 1; @@ -27,17 +49,17 @@ counter = counter + 1; end -if iscell(original_tifs) - original_files_tmp = struct("name", '', "folder", '', "date", '',... - "bytes", 0, "isdir", false, "datenum", 0); - for i = 1:length(original_tifs) - if i == 1 - original_files_tmp(1:length(original_tifs{i})) = original_tifs{i}; - else - original_files_tmp(end + 1:end + length(original_tifs{i})) = original_tifs{i}; - end - end - original_tifs = original_files_tmp; -end +% if iscell(original_tifs) +% original_files_tmp = struct("name", '', "folder", '', "date", '',... +% "bytes", 0, "isdir", false, "datenum", 0); +% for i = 1:length(original_tifs) +% if i == 1 +% original_files_tmp(1:length(original_tifs{i})) = original_tifs{i}; +% else +% original_files_tmp(end + 1:end + length(original_tifs{i})) = original_tifs{i}; +% end +% end +% original_tifs = original_files_tmp; +% end end diff --git a/utilities/getOriginalTIFsFromStandardFolder.m b/utilities/getOriginalTIFsFromStandardFolder.m old mode 100755 new mode 100644 index 181410c..0537b38 --- a/utilities/getOriginalTIFsFromStandardFolder.m +++ b/utilities/getOriginalTIFsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function original_tifs = getOriginalTIFsFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getPixelSizeFromHeader.m b/utilities/getPixelSizeFromHeader.m old mode 100755 new mode 100644 index 73b1914..489413a --- a/utilities/getPixelSizeFromHeader.m +++ b/utilities/getPixelSizeFromHeader.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function apix = getPixelSizeFromHeader(file_path, log_file_id) if iscell(file_path) command = sprintf("header %s", file_path{1}); diff --git a/utilities/getTemplate.m b/utilities/getTemplate.m old mode 100755 new mode 100644 index 8d5879a..d518cab --- a/utilities/getTemplate.m +++ b/utilities/getTemplate.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function template = getTemplate(configuration, path) file_path = configuration.processing_path + string(filesep)... + configuration.output_folder + string(filesep)... diff --git a/utilities/getTiltAngles.m b/utilities/getTiltAngles.m index a74e50a..d775eee 100644 --- a/utilities/getTiltAngles.m +++ b/utilities/getTiltAngles.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_angles = getTiltAngles(configuration, get_all_angles) if nargin == 1 get_all_angles = false; diff --git a/utilities/getTiltIndexAngleMapping.m b/utilities/getTiltIndexAngleMapping.m old mode 100755 new mode 100644 index e3cf66f..5202249 --- a/utilities/getTiltIndexAngleMapping.m +++ b/utilities/getTiltIndexAngleMapping.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_index_angle_mapping = getTiltIndexAngleMapping(configuration) meta_data_path = configuration.processing_path + string(filesep)... + configuration.output_folder + string(filesep)... diff --git a/utilities/getTiltStacks.m b/utilities/getTiltStacks.m old mode 100755 new mode 100644 index 1213f88..c464251 --- a/utilities/getTiltStacks.m +++ b/utilities/getTiltStacks.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getTiltStacks(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getTiltStacksFromPreviousPipelineStepFolders.m b/utilities/getTiltStacksFromPreviousPipelineStepFolders.m old mode 100755 new mode 100644 index b727e1b..3d960bb --- a/utilities/getTiltStacksFromPreviousPipelineStepFolders.m +++ b/utilities/getTiltStacksFromPreviousPipelineStepFolders.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getTiltStacksFromPreviousPipelineStepFolders(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getTiltStacksFromStandardFolder.m b/utilities/getTiltStacksFromStandardFolder.m old mode 100755 new mode 100644 index 3e57c65..00097ca --- a/utilities/getTiltStacksFromStandardFolder.m +++ b/utilities/getTiltStacksFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tilt_stacks = getTiltStacksFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getTltxfFilePaths.m b/utilities/getTltxfFilePaths.m old mode 100755 new mode 100644 index be2024a..ca7a6d0 --- a/utilities/getTltxfFilePaths.m +++ b/utilities/getTltxfFilePaths.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tiltxf_file_paths = getTltxfFilePaths(configuration) original_mrcs = getOriginalMRCsFromStandardFolder(configuration); batchruntomo_folders = dir(configuration.processing_path + string(filesep)... diff --git a/utilities/getTomograms.m b/utilities/getTomograms.m old mode 100755 new mode 100644 index b2b99c0..6737a69 --- a/utilities/getTomograms.m +++ b/utilities/getTomograms.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tomograms = getTomograms(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getTomogramsFromPreviousPipelineStepFolders.m b/utilities/getTomogramsFromPreviousPipelineStepFolders.m old mode 100755 new mode 100644 index 33c218b..aab3565 --- a/utilities/getTomogramsFromPreviousPipelineStepFolders.m +++ b/utilities/getTomogramsFromPreviousPipelineStepFolders.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tomograms = getTomogramsFromPreviousPipelineStepFolders(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getTomogramsFromStandardFolder.m b/utilities/getTomogramsFromStandardFolder.m old mode 100755 new mode 100644 index 7d50d87..f2d0951 --- a/utilities/getTomogramsFromStandardFolder.m +++ b/utilities/getTomogramsFromStandardFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function tomograms = getTomogramsFromStandardFolder(configuration, flatten) if nargin == 1 flatten = false; diff --git a/utilities/getUnprocessedTomograms.m b/utilities/getUnprocessedTomograms.m old mode 100755 new mode 100644 index 5fbaebb..d8e3fea --- a/utilities/getUnprocessedTomograms.m +++ b/utilities/getUnprocessedTomograms.m @@ -1,19 +1,47 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [dynamic_configuration, file_count_changed] = getUnprocessedTomograms(configuration, log_file_id) dynamic_configuration = struct; original_files = getOriginalFiles(configuration, false); original_files = original_files(~startsWith({original_files.name}, ".")); -if checkForMultipleExtensions({original_files.name}); +if ~isempty(original_files) && checkForMultipleExtensions({original_files.name}) error("ERROR: Multiple unknown extensions found!"); end file_count = length(original_files); if ~isfield(configuration, "file_count") || (isfield(configuration, "file_count") && (configuration.file_count < file_count)) dynamic_configuration.file_count = length(original_files); - file_count_changed = true; + if isempty(original_files) + file_count_changed = false; + return; + else + file_count_changed = true; + end else dynamic_configuration.file_count = configuration.file_count; dynamic_configuration.tomograms_count = configuration.tomograms_count; - dynamic_configuration.starting_tomogram = configuration.starting_tomogram; + if ~isfield(configuration, "starting_tomogram") + dynamic_configuration.starting_tomogram = 1; + else + dynamic_configuration.starting_tomogram = configuration.starting_tomogram; + end file_count_changed = false; return; end @@ -226,6 +254,29 @@ dynamic_configuration.original_files(i).tilt_stack = true; dynamic_configuration.tilt_stacks = true; end + + % re-write with the user-enforced parameters values if present + % NOTE:TODO: dirty, subject for later refactoring! + if isfield(configuration, "tomogram_number_position") && configuration.tomogram_number_position ~= -1 + dynamic_configuration.original_files(i).tomogram_number_position = configuration.tomogram_number_position; + end + + if isfield(configuration, "tilt_number_position") && configuration.tilt_number_position ~= -1 + dynamic_configuration.original_files(i).tilt_number_position = configuration.tilt_number_position; + end + + if isfield(configuration, "angle_position") && configuration.angle_position ~= -1 + dynamic_configuration.original_files(i).angle_position = configuration.angle_position; + end + + if isfield(configuration, "date_position") && configuration.date_position ~= -1 + dynamic_configuration.original_files(i).date_position = configuration.date_position; + end + + if isfield(configuration, "time_position") && configuration.time_position ~= -1 + dynamic_configuration.original_files(i).time_position = configuration.time_position; + end + end %[values, indices] = sort({dynamic_configuration.original_files.name}); @@ -380,7 +431,7 @@ else tomogram_file_indices = start_indices(i + 1):start_indices(i + 2)-1; end - + disp("INFO: Number of files available: " + num2str(length(tomogram_file_indices))); if length(tomogram_file_indices) < configuration.minimum_files disp("INFO: Not enough files for this tomogram to do reconstructions!"); dynamic_configuration.tomograms.(tomogram_name).skipped = true; @@ -445,6 +496,14 @@ dynamic_configuration.tomograms.(tomogram_name).adjusted_tilt_number_position = dynamic_configuration.original_files(tomogram_file_indices(1)).adjusted_tilt_number_position; dynamic_configuration.tomograms.(tomogram_name).date_position = dynamic_configuration.original_files(tomogram_file_indices(1)).date_position; dynamic_configuration.tomograms.(tomogram_name).time_position = dynamic_configuration.original_files(tomogram_file_indices(1)).time_position; + + if isfield(configuration, "live_data_mode") && configuration.live_data_mode == true + [~, last_collected_frame_name, ~] = fileparts(sorted_files(tomogram_file_indices(end))); + last_collected_frame_name_split = strsplit(last_collected_frame_name, '_'); + dynamic_configuration.tomograms.(tomogram_name).last_collected_frame_date = last_collected_frame_name_split(dynamic_configuration.tomograms.(tomogram_name).date_position); + dynamic_configuration.tomograms.(tomogram_name).last_collected_frame_time = last_collected_frame_name_split(dynamic_configuration.tomograms.(tomogram_name).time_position); + end + dynamic_configuration.tomograms.(tomogram_name).zero_tilt = [dynamic_configuration.original_files(tomogram_file_indices).zero_tilt]; [sorted_angle_values, sorted_angle_indices] = sort([dynamic_configuration.original_files(tomogram_file_indices).angle]); dynamic_configuration.tomograms.(tomogram_name).sorted_angles = sorted_angle_values; @@ -520,7 +579,11 @@ current_tomogram = current_tomogram + 1; end end -dynamic_configuration.starting_tomogram = current_tomogram; + +if ~isfield(configuration, "live_data_mode") || configuration.live_data_mode == false + dynamic_configuration.starting_tomogram = current_tomogram; +end + end diff --git a/utilities/getXfOrAlnFilePaths.m b/utilities/getXfOrAlnFilePaths.m new file mode 100644 index 0000000..c942d02 --- /dev/null +++ b/utilities/getXfOrAlnFilePaths.m @@ -0,0 +1,44 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function xf_file_path = getXfOrAlnFilePaths(configuration, output_path, tomogram_name) +xf_file_path = getFilesFromLastModuleRun(configuration,"AreTomo","xf","last"); +if ~isempty(xf_file_path) + xf_file_path = xf_file_path{1}; +else + xf_file_path = getFilesFromLastModuleRun(configuration,"AreTomo","aln","last"); + if isempty(xf_file_path) + xf_file_path = getFilePathsFromLastBatchruntomoRun(configuration, "xf"); + xf_file_path = xf_file_path{1}; + else + fid_in = fopen(xf_file_path{1}); + lines_in_cells = textscan(fid_in, "%s","Delimiter","\n"); + fclose(fid_in); + fid_out = fopen(output_path + filesep + tomogram_name + ".xf", "w+"); + for j = 4:length(lines_in_cells{1}) + numbers_in_line = textscan(lines_in_cells{1}{j}, "%f %f %f %f %f %f %f %f %f %f"); + rotation_matrix = rotz(numbers_in_line{2}); + fprintf(fid_out, "%f %f %f %f %f %f\n", rotation_matrix(1,1), rotation_matrix(1,2), rotation_matrix(2,1), rotation_matrix(2,2), numbers_in_line{4}, numbers_in_line{5}); + end + fclose(fid_out); + xf_file_path = output_path + filesep + tomogram_name + ".xf"; + end +end +end + diff --git a/utilities/gpuEllipsoid.m b/utilities/gpuEllipsoid.m old mode 100755 new mode 100644 index 2473df8..d55eb66 --- a/utilities/gpuEllipsoid.m +++ b/utilities/gpuEllipsoid.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function vol = gpuEllipsoid(radii,siz,position,smoothing_pixels) if ndims(siz) > 2 siz = size(siz); diff --git a/utilities/gpuEulerToMatrix.m b/utilities/gpuEulerToMatrix.m old mode 100755 new mode 100644 index ede2cb9..cfa57c9 --- a/utilities/gpuEulerToMatrix.m +++ b/utilities/gpuEulerToMatrix.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function transformation_matrices = gpuEulerToMatrix(angles, varargin) defaultMatrixOperation = "crotation"; diff --git a/utilities/histogramEqualization.m b/utilities/histogramEqualization.m old mode 100755 new mode 100644 index fdb2e08..4845a42 --- a/utilities/histogramEqualization.m +++ b/utilities/histogramEqualization.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % NOTE: https://stackoverflow.com/questions/26763974/histogram-matching-of-two-images-without-using-histeq function output_image = histogramEqualization(image_1, image_2) bin_counts = 2^16; diff --git a/utilities/increaseFolderNumber.m b/utilities/increaseFolderNumber.m old mode 100755 new mode 100644 index d115caf..5312472 --- a/utilities/increaseFolderNumber.m +++ b/utilities/increaseFolderNumber.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [folder, previous_folder] = increaseFolderNumber(configuration, folder) dir_list = dir(folder + "*"); if ~isempty(dir_list) && configuration.increase_folder_numbers == true diff --git a/utilities/iteration.m b/utilities/iteration.m old mode 100755 new mode 100644 index 31df297..3997a3e --- a/utilities/iteration.m +++ b/utilities/iteration.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [dynamic_configuration_out, status] = iteration(merged_configuration, pipeline_definition, tomogram_name, previous_tomogram_status) dynamic_configuration_out = struct; if isfield(merged_configuration, "skip") && merged_configuration.skip == true diff --git a/utilities/loadJSON.m b/utilities/loadJSON.m old mode 100755 new mode 100644 index 6fe21ca..d131871 --- a/utilities/loadJSON.m +++ b/utilities/loadJSON.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function configuration = loadJSON(file_path) fid = fopen(file_path); text = fscanf(fid, "%s"); diff --git a/utilities/makeEvenVolumeDimensions.m b/utilities/makeEvenVolumeDimensions.m old mode 100755 new mode 100644 index a6ef5c5..84c53a6 --- a/utilities/makeEvenVolumeDimensions.m +++ b/utilities/makeEvenVolumeDimensions.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function volume_out = makeEvenVolumeDimensions(volume_in, mean_value) if mod(length(volume_in), 2) == 1 % TODO: adjust for non cubic sizes diff --git a/utilities/mergeConfigurations.m b/utilities/mergeConfigurations.m old mode 100755 new mode 100644 index f190264..250e04f --- a/utilities/mergeConfigurations.m +++ b/utilities/mergeConfigurations.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function merged_configurations = mergeConfigurations(first_configuration, second_configuration, pipeline_step, script_name) printVariable(first_configuration); printVariable(second_configuration); diff --git a/utilities/ownDbox.m b/utilities/ownDbox.m index c1667e1..6e76b73 100644 --- a/utilities/ownDbox.m +++ b/utilities/ownDbox.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function ownDbox(source_folder, destination_folder, batch, delete_source_folder, padding) if nargin < 2 error("ERROR: to create dbox folder source and destination is needed!"); diff --git a/utilities/printToFile.m b/utilities/printToFile.m old mode 100755 new mode 100644 index 6d492a2..cc993a8 --- a/utilities/printToFile.m +++ b/utilities/printToFile.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function printToFile(file_id, message) fprintf(file_id, "%s\n", message); end diff --git a/utilities/printVariable.m b/utilities/printVariable.m old mode 100755 new mode 100644 index 9145ae8..f796dbd --- a/utilities/printVariable.m +++ b/utilities/printVariable.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % NOTE: works only for named variables function printVariable(variable, debug) if nargin == 1 diff --git a/utilities/printVariableToString.m b/utilities/printVariableToString.m old mode 100755 new mode 100644 index 79f363d..262ce03 --- a/utilities/printVariableToString.m +++ b/utilities/printVariableToString.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % NOTE: works only for named variables function variable_string = printVariableToString(variable) if iscell(variable) diff --git a/utilities/readConfigurationsFromFolder.m b/utilities/readConfigurationsFromFolder.m old mode 100755 new mode 100644 index 62067c7..c443932 --- a/utilities/readConfigurationsFromFolder.m +++ b/utilities/readConfigurationsFromFolder.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function configurations = readConfigurationsFromFolder(folder) configuration_file_path = dir(folder + string(filesep) + "output.json"); if isempty(configuration_file_path) diff --git a/utilities/removeDynamoLinks.m b/utilities/removeDynamoLinks.m old mode 100755 new mode 100644 index 1c4e9f4..339239e --- a/utilities/removeDynamoLinks.m +++ b/utilities/removeDynamoLinks.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function removeDynamoLinks() linked_files = getDynamoFiles("dynamo"); diff --git a/utilities/saveJSON.m b/utilities/saveJSON.m old mode 100755 new mode 100644 index e70ce26..13cfbef --- a/utilities/saveJSON.m +++ b/utilities/saveJSON.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function saveJSON(path, variable) fid_json = fopen(path, "wt" ); variable_json = jsonencode(variable, "ConvertInfAndNaN", false); diff --git a/utilities/sortDirOutputByPipelineStepNumbering.m b/utilities/sortDirOutputByPipelineStepNumbering.m old mode 100755 new mode 100644 index ed447ac..70aaed9 --- a/utilities/sortDirOutputByPipelineStepNumbering.m +++ b/utilities/sortDirOutputByPipelineStepNumbering.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function order = sortDirOutputByPipelineStepNumbering(dir_list, configuration) for j = 1:length(dir_list) dir_list_real_indices{j} = strsplit(dir_list(j).name, "_"); diff --git a/utilities/template_matching_post_processing_iteration.m b/utilities/template_matching_post_processing_iteration.m old mode 100755 new mode 100644 index d593d7e..5312731 --- a/utilities/template_matching_post_processing_iteration.m +++ b/utilities/template_matching_post_processing_iteration.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function [tab_tomo, temporary_files] = template_matching_post_processing_iteration(configuration, binned_tomograms_paths_filtered, output_path, mask_erase) [folder, name, extension] = fileparts(binned_tomograms_paths_filtered.folder); name_splitted = strsplit(name, "_"); @@ -101,7 +120,13 @@ counter = 0; while true [a, b] = dynamo_peak_subpixel(cc); - + + if isreal(a) == false + % NOTE: dynamo_peak_subpixel returns complex values + % when interpolation in that function somehow failed + break; + end + if configuration.particle_count == counter && configuration.particle_count > 0 break; end diff --git a/utilities/versionGreaterThan.m b/utilities/versionGreaterThan.m old mode 100755 new mode 100644 index a8a3b50..91400e0 --- a/utilities/versionGreaterThan.m +++ b/utilities/versionGreaterThan.m @@ -1,3 +1,22 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This file is part of the TomoBEAR software. +% Copyright (c) 2021-2023 TomoBEAR Authors +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU Affero 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 +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU Affero General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see . +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + function result = versionGreaterThan(version, version_to_be_compared_to, delimiter) if nargin == 2 delimiter = "."; diff --git a/wiki/Additional-Software-Citation.md b/wiki/Additional-Software-Citation.md new file mode 100644 index 0000000..576ebde --- /dev/null +++ b/wiki/Additional-Software-Citation.md @@ -0,0 +1,62 @@ +# Additional Software Citations + +As ```TomoBEAR``` wraps different third-party software packages for different processing stages, these need to be properly cited, once used under ```TomoBEAR```. Please, note that by using these software packages you are assumed to read the corresponding license files and fully accept them. + +#### IMOD + +General usage: +- Mastronarde DN & Held SR (2017) Automated tilt series alignment and tomographic +reconstruction in IMOD. *J Struct Biol* 197: 102–113. DOI: [10.1016/j.jsb.2016.07.011](https://www.sciencedirect.com/science/article/pii/S1047847716301526?via%3Dihub) + +Non-linear Anisotropic Diffusion filter: +- Frangakis A & Hegerl R (2001) Noise reduction in electron tomographic reconstructions using nonlinear anisotropic diffusion. *J Struct Biol* 135: 239-205. DOI: [10.1006/jsbi.2001.4406](https://www.sciencedirect.com/science/article/pii/S1047847701944065?via%3Dihub). + +#### Dynamo + +Main reference for its usage under TomoBEAR: +- Castaño-Díez D, Kudryashev M, Arheit M & Stahlberg H (2012) Dynamo: A flexible, user-friendly development tool for subtomogram averaging of cryo-EM data in high-performance computing environments. *J Struct Biol* 186:139-151. DOI: [10.1016/j.jsb.2011.12.017](https://www.sciencedirect.com/science/article/pii/S1047847711003650?via%3Dihub) + +If you pick particles manually using Dynamo Catalogue as well, please cite also the following publication: +- Castaño-Díez D, Kudryashev M & Stahlberg H (2016) Dynamo Catalogue: Geometrical tools +and data management for particle picking in subtomogram averaging of cryo-electron +tomograms. *J Struct Biol* 197(2):135-144. DOI: [10.1016/j.jsb.2016.06.005](https://www.sciencedirect.com/science/article/pii/S1047847716301113?via%3Dihub) + +#### MotionCor2 + +- Zheng SQ, Palovcak E, Armache J-P, Verba KA, Cheng Y & Agard DA (2017) MotionCor2: +anisotropic correction of beam-induced motion for improved cryo-electron microscopy. *Nat Methods* 14: 331–332. DOI: [10.1038/nmeth.4193](https://www.nature.com/articles/nmeth.4193) + +#### AreTomo + +- Zheng S, Wolff G, Greenan G, Chen Z, Faas FGA, Bárcena M, Koster AJ, Cheng Y & Agard DA +(2022) AreTomo: An integrated software package for automated marker-free, +motion-corrected cryo-electron tomographic alignment and reconstruction. *J Struct Biol X* +6: 100068. DOI: [10.1016/j.yjsbx.2022.100068](https://www.sciencedirect.com/science/article/pii/S2590152422000095?via%3Dihub) + +#### Gctf + +For all three GCTF versions usage (v1.06/v1.18/Gautomatch cu10.1) please cite the following publication: +- Zhang K (2016) Gctf: Real-time CTF determination and correction. *J Struct Biol* 193: 1–12. DOI: [10.1016/j.jsb.2015.11.003](https://www.sciencedirect.com/science/article/pii/S1047847715301003?via%3Dihub) + +#### CTFFIND4 + +CTFFIND4: +- Rohou A & Grigorieff N (2015) CTFFIND4: Fast and accurate defocus estimation from electron micrographs. *J Struct Biol* 192(2): 216-221. DOI: [10.1016/j.jsb.2015.08.008](https://www.sciencedirect.com/science/article/pii/S1047847715300460?via%3Dihub) + +CTFFIND4 from cisTEM package: +- Grant T, Rohou A & Grigorieff N (2018) cisTEM, user-friendly software for single-particle image processing. *Elife* 7: e35383. DOI: [10.7554/eLife.35383](https://elifesciences.org/articles/35383) + +#### IsoNet + +- Liu YT, Zhang H, Wang H et al. (2022) Isotropic reconstruction for electron tomography with deep learning. *Nat Commun* 13: 6482. DOI: [10.1038/s41467-022-33957-8](https://www.nature.com/articles/s41467-022-33957-8) + +#### CryoCARE + +- Buchholz TO, Jordan M, Pigino G & Jug F (2018) Cryo-CARE: Content-Aware Image Restoration for Cryo-Transmission Electron Microscopy Data. *arXiv* arXiv:1810.05420. DOI: [10.48550/arXiv.1810.05420](https://arxiv.org/abs/1810.05420) + + +#### SUSAN + +If you used SUSAN, please, cite as the following: + +- Sánchez RM (2023) rkms86/SUSAN: Release for TomoBEAR (v0.1-RC1-TomoBEAR). *Zenodo*. DOI: [10.5281/zenodo.7950904](https://doi.org/10.5281/zenodo.7950904) diff --git a/wiki/Frequently-Asked-Questions.md b/wiki/Frequently-Asked-Questions.md index e8cf82a..a940647 100644 --- a/wiki/Frequently-Asked-Questions.md +++ b/wiki/Frequently-Asked-Questions.md @@ -1,3 +1,5 @@ +# Frequently asked questions + Here you can find frequently asked questions which appear from time to time when you process data with `TomoBEAR`: 1. What can I do if `TomoBEAR` outputs `out of memory` error during execution of the module `DynamoTiltSeriesAlignment`? diff --git a/wiki/Home.md b/wiki/Home.md index 7c5eee6..f6de14c 100644 --- a/wiki/Home.md +++ b/wiki/Home.md @@ -1,49 +1,54 @@ # Welcome to the TomoBEAR wiki! -*Currently we are at the experimental release stage, we will be happy if you try it. Please report to [Issue Tracker system](https://github.com/KudryashevLab/TomoBEAR/issues) or write to us in you have problems:* +![TomoBEAR Social Media Logo Image](/images/TomoBEAR_gitlogo.png) -- [Artsemi Yushkevich (Contributing Developer)](mailto:Artsemi.Yushkevich@mdc-berlin.de?subject=[GitHub]%20TomoBEAR) - Ph.D. student in the [In situ Structural Biology Group](https://www.mdc-berlin.de/kudryashev) at the [MDC Berlin (Max Delbrück Center of Molecular Medicine)](https://www.mdc-berlin.de) in Berlin, Germany and/or +**B**asics for cryo-**E**lectron **tomo**graphy and **A**utomated **R**econstruction (**TomoBEAR**) is a configurable and customizable open-source MATLAB software package developed for automated large-scale parallelized cryo-electron tomography (cryo-ET) data processing. -- [Misha Kudryashev (Project Leader)](mailto:misha.kudryashev@gmail.com?subject=[GitHub]%20TomoBEAR) - Principal Investigator, head of the [In situ Structural Biology Group](https://www.mdc-berlin.de/kudryashev) at the [MDC Berlin (Max Delbrück Center of Molecular Medicine)](https://www.mdc-berlin.de) in Berlin, Germany. +> **Note** +>
Implementation details and benchmarks you can find in our preprint: +
Balyschew N, Yushkevich A, Mikirtumov V, Sanchez RM, Sprink T, Kudryashev M. Streamlined Structure Determination by Cryo-Electron Tomography and Subtomogram Averaging using TomoBEAR. **[Preprint]** 2023. bioRxiv doi: [10.1101/2023.01.10.523437](https://www.biorxiv.org/content/10.1101/2023.01.10.523437v1) -### Wiki contents +## Wiki contents -This wiki contains... -1. general description (below on this page) -2. description on how to [install and setup](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup) TomoBEAR -3. list of [Frequently Asked Questions](https://github.com/KudryashevLab/TomoBEAR/wiki/Frequently-Asked-Questions) -4. [tutorial](https://github.com/KudryashevLab/TomoBEAR/wiki/Tutorials) as the example of TomoBEAR project preparation and execution -5. description on [all the available modules, their parameters and default values](https://github.com/KudryashevLab/TomoBEAR/wiki/Modules) -6. TomoBEAR [usage tips](https://github.com/KudryashevLab/TomoBEAR/wiki/Usage) +- [General description of the pipeline](#general-description) +- [Installation and setup notes](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup) +- [Frequently Asked Questions](https://github.com/KudryashevLab/TomoBEAR/wiki/Frequently-Asked-Questions) +- [Tutorials on TomoBEAR setup and usage](https://github.com/KudryashevLab/TomoBEAR/wiki/Tutorials) +- [Available modules description, their parameters and default values](https://github.com/KudryashevLab/TomoBEAR/wiki/Modules) +- [Usage cases and tips](https://github.com/KudryashevLab/TomoBEAR/wiki/Usage) +- [List of external software to be cited](https://github.com/KudryashevLab/TomoBEAR/wiki/Additional-Software-Citation) ## Gerenal description -TomoBEAR is a configurable and customizable software package specialized for cryo-electron tomography and subtomogram averaging completely written in the MATLAB scripting language. TomoBEAR implements **B**asics for **E**lectron tomography and **A**utomated **R**econstruction of cryo electron tomography data. With TomoBEAR you can easily process tomographic data acquired by an electron microscope starting from the raw tilt series, possibly dose fractionated, or already assembled tilt stacks to the biological structure of interest. +**TomoBEAR** can assist you in large-scale processing of the tomographic data acquired on the electron microscope starting from the raw tilt series, possibly dose fractionated, or already assembled tilt stacks up to sample volume 3D reconstruction and even to biological structure of interest. More on input formats you [can read here](https://github.com/KudryashevLab/TomoBEAR/wiki/Usage.md#input-data-file-formats). -TomoBEAR is designed to operate on a data set in parallel where it is possible and that the user has minimal intervention and doesn't need to learn all the different software packages (MotionCor2, IMOD, Gctf, Dynamo) to be able to process cryo-electron tomography data. We tried to come up with a set of predefined defaults which should fit many projects in the cryo-electron tomography regime. However if some parameters need to be tweaked for specific projects to achieve best results you are free to do so. +**TomoBEAR** is designed to operate in automated manner minimizing user intervention where that is possible. The pipeline consists of modules, which wrap popular cryo-ET tools (such as IMOD, Dynamo, MotionCor2, GCTF/CTFFIN4, etc.) as well as developed in our laboratory StA framework called [SUSAN](https://github.com/rkms86/SUSAN). + +Since number of **TomoBEAR** parameters is huge, to help users cope with that we have carefully designed a predefined set of defaults which were chosen based on several different cryo-ET datasets. Description of all modules and corresponding default values is given on the [Modules page](https://github.com/KudryashevLab/TomoBEAR/wiki/Modules). + +> **Note** +>
`TomoBEAR` supports workstations and single interactive nodes with GPUs on the comuting clusters at the moment. We are also working towards enabling the support of computer clusters through a queue manager like SLURM or SGE (Sun Grid Engine).
List of reasons to use TomoBEAR

-* TomoBEAR is based on best practices in processing tomographic data * Uses default presets which work on a variety of tested datasets * Standalone and MATLAB versions are available * Parallel execution is possible * Computing resources are configurable -* Supports SLURM cluster scheduler * Standardized folder structure * Can deal with * misnumbered tilt images due to SerialEM crashes, based on timestamps * different naming conventions - * EERs, MRCs and TIFs from K2 and K3 + * EERs, MRCs and TIFs from K2, K3, Falcon4 * duplicated projections due to tracking issues (first, last, keep) * Restarting / resuming is possible (e.g. in case of errors, wrong configuration) * Checkpoints are created after every processing step of a tilt series or tomogram -* TomoBEAR is based on JSON configuration files which can be easily shared between others so that they can validate or improve your results -* TomoBEAR was developed and tested on standard datasets to achieve same or better results as with manual processing +* Based on JSON configuration files which can be easily shared between others so that they can validate or improve your results +* Developed and tested on standard benchmarking datasets (such as EMPIAR-10064) to achieve same or better results as with manual processing * You are able to look at the intermediates optimize parameters and rerun the steps to achieve optimal results -* You are never locked to the tomoBEAR processing pipeline and can easily breakout at various steps to other software tools you prefer +* You are never locked to the TomoBEAR processing pipeline and can easily breakout at various steps to other software tools you prefer * Uses links where possible * Clean up functionality to save storage * Tomograms to be processed can be limited to a subset @@ -69,28 +74,8 @@ TomoBEAR is designed to operate on a data set in parallel where it is possible a

## Pipeline structure -In the following picture you can see a flow chart which visualizes which steps `TomoBEAR` will and can do for you in an automated and parallel manner. `TomoBEAR` supports workstations and single interactive nodes with GPUs on the comuting clusters at the moment. We are also working towards enabling the support of computer clusters through a queue manager like SLURM or SGE (Sun Grid Engine). - -Note that it is not needed to start from raw data but you can also use already assembled tilt stacks if you provide the angular information. +In the following picture you can see a flow chart which visualizes pipeline steps which `TomoBEAR` can execute in an automated and parallel manner. -![Schematic Pipeline Image Light Mode](https://raw.githubusercontent.com/KudryashevLab/TomoBEAR/main/images/pipeline_light_mode.svg#gh-light-mode-only) -![Schematic Pipeline Image Dark Mode](https://raw.githubusercontent.com/KudryashevLab/TomoBEAR/main/images/pipeline_dark_mode.svg#gh-dark-mode-only) +![Schematic Pipeline Image](/images/pipeline_light_mode.svg) Orange processing steps in the flow chart are mandatory and must be executed by TomoBEAR. Yellow boxes are optional and can be activated if desired. - -## Results example (the tutorial case) - -The result shown here have been achieved in an automated manner. The only manual task which needed to be done is the choice of the classes for further processing in between the transition of different binning levels. - -### EMPIAR-10064 - -On the EMPIAR-10064 dataset `TomoBEAR` achieved 11.25 Angstrom (with ~4k particles) as can be seen below on the FSC curve plot: -

-Ribosome EMPIAR-10064 FSC -

- -As well, below is provided ribosome final map view: - -

-Ribosome EMPIAR-10064 Map -

diff --git a/wiki/Installation-and-Setup.md b/wiki/Installation-and-Setup.md index d7fa122..6049638 100644 --- a/wiki/Installation-and-Setup.md +++ b/wiki/Installation-and-Setup.md @@ -1,7 +1,7 @@ -Currently we are at the stage of testing, we will be happy if you try it, we will help you to get going. Please get back to us by using our [Issue Tracker](https://github.com/KudryashevLab/TomoBEAR/issues) or write to -[Artsemi Yushkevich](mailto:Artsemi.Yushkevich@mdc-berlin.de?subject=[GitHub]%20TomoBEAR) if you have problems. +# Installation and setup -:tada:**The first standalone executable release for GPU workstations is available now! :tada: You may find it on the [Releases page](https://github.com/KudryashevLab/TomoBEAR/releases).** +> **Note** +>
If you experience problems with TomoBEAR installation, do not hestitate to communicate with us by one of mentioned ways in [Feedback and Contribution](https://github.com/KudryashevLab/TomoBEAR#feedback-and-contribution) section. # Prerequisites @@ -30,50 +30,92 @@ There are two ways to operate TomoBEAR. * The first way is to [[ use it directly from MATLAB | https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#matlab ]] * The second way is to [[ use a standalone executable which is available precompiled | https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#standalone ]] -For both methods of operation, you will need to get TomoBEAR source code and to get and install its dependencies. Thus, you have to install essential dependencies (Dynamo, IMOD, MotionCor2 and GCTF) and may additionally install optional ones (SUSAN, AreTomo, etc.). The corresponding links you may find in the section [[ Additional software | https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#additional-software ]]. +For both methods of operation, you will need to [[ get TomoBEAR source code | https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#get-source-code-and-binary ]] and to get and install its dependencies. -## MATLAB +You have to install essential TomoBEAR dependencies (CUDA, Dynamo, and IMOD) and may additionally install optional ones (MotionCor2, GCTF, etc.). The corresponding links you may find in the section [[ Additional software | https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#additional-software ]]. -If you want to run on a local machine then it is advised to run TomoBEAR from within MATLAB. This way you also don't need to download and install the MATLAB Compiled Runtime (MCR) if it is not already installed in your facility. +## Video-tutorial -It is adviced to use the following MATLAB release under which the software was tested: MATLAB R2021a. +We have prepared a small video-tutorial explaining the most basic `TomoBEAR` setup, which is needed for our [80S ribosome data processing tutorial](https://github.com/KudryashevLab/TomoBEAR/wiki/Tutorials): +* [Video-tutorial](https://drive.google.com/file/d/1Nhltdo7DbWdzPhAbnkzq7lCkDghxJrku/view?usp=share_link) explaining how to get the latest ```TomoBEAR``` version and configure ```TomoBEAR``` and its dependencies. -Everything you need to get TomoBEAR on your machine is to change to some folder where you want to have TomoBEAR and execute the following command +For more detailed or specific instructions please look at the further chapters provided on this page. -* `git clone https://github.com/KudryashevLab/tomoBEAR.git`. +## Get source code and binary -After that change to the folder TomoBEAR with +### Clone the latest version -* `cd tomoBEAR` +To get the latest ```TomoBEAR``` version you can simply clone *main* branch by: +```bash + git clone https://github.com/KudryashevLab/TomoBEAR.git +``` -Inside of the tomoBEAR folder you will find a configurations folder in which the file `defaults.json` can be found. Open the file `defaults.json` and adjust the following variables inside the general section +### Clone specific version -* `"pipeline_location": ""` put in the double quotes the location of cloned TomoBEAR -* `"motion_correction_command": ""` put in the double quotes the executable name of MotionCor2 or the full path (with the executable name) -* `"ctf_correction_command": ""` put in the double quotes the executable name of Gctf or the full path (with the executable name) -* `"dynamo_path": ""` put in the double quotes the path to your dynamo folder +To get a specific version of the ```TomoBEAR``` you need to create the following ```install_TomoBEAR.sh``` installation bash script: -Optionally you can set up as well the following variables inside the `"general"` section: +```bash +VER=${1} +INSTALL_DIR=$(readlink -f ./${2}) +echo "Installing TomoBEAR-v"${VER} "in the directory " ${INSTALL_DIR} + +echo "Fetching and unpacking source code from GitHub..." +mkdir -p ${INSTALL_DIR} +cd ${INSTALL_DIR} +wget https://github.com/KudryashevLab/TomoBEAR/archive/refs/tags/v${VER}.tar.gz +tar zxvf v${VER}.tar.gz +ln -s TomoBEAR-${VER} ${VER} +``` -* `"aretomo_command": ""` put in the double quotes the executable name of AreTomo or the full path (with the executable name) -* `"SUSAN_path": ""` put in the double quotes the location of cloned SUSAN +If binary was also applied to the release which you want to get, you need to add as well the following lines to the ```install_TomoBEAR.sh```: +``` +echo "Fetching and activating binary..." +cd ${VER} +wget https://github.com/KudryashevLab/TomoBEAR/releases/download/v${VER}/TomoBEAR-${VER} +chmod +x TomoBEAR-${VER} +ln -s TomoBEAR-${VER} TomoBEAR +rm -f ../v${VER}.tar.gz +``` +To use it, activate it by +```bash +chmod +x install_TomoBEAR.sh +``` +and execute as the following +```bash +./install_TomoBEAR.sh X.Y.Z /path/to/dir +``` +where ```X.Y.Z``` is the version of the release (e.g., 0.3.0) and ```/path/to/dir``` is the path to the folder where to put the TomoBEAR source code. -If you use the Linux module system please insert the module names which need to be loaded to make all the necessary software available and working in the following variable in the general section +The list of available releases can be found on the [Releases page](https://github.com/KudryashevLab/TomoBEAR/releases). -* `"modules": ["IMOD_module", "Gctf_module", "MotionCor2_module", "CUDA_module_1", "CUDA_module_2"]` +> **Note** +>
We are grateful to Wolfgang Lugmayr (CSSB, Hamburg) for the installation script idea. + +## Initialize TomoBEAR + +### MATLAB + +If you want to run on a local machine then it is advised to run TomoBEAR from within MATLAB. This way you also don't need to download and install the MATLAB Compiled Runtime (MCR) if it is not already installed in your facility. + +It is adviced to use the following MATLAB release under which the software was tested: MATLAB R2021a. -Afterwards start MATLAB with the command +Further you need to install TomoBEAR's dependencies, at least all mandatory ones: CUDA, Dynamo and IMOD. For the corresponding links and some instructions on that refer to the section [Additional Software](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#additional-software). + +Afterwards you need to configure and initialize TomoBEAR with the corresponding paths to the dependencies. Instructions on that part you may find below in the subsection [Configure installed software](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#configure-installed-software) + +Finally, start MATLAB with the command * `./run_matlab.sh` To be able to run that MATLAB should be in your system's `PATH` variable. The first time you start TomoBEAR after cloning it, initialization of necessary paths will be automatically performed, which could take a couple of minutes. But no worries, this is happening only once per the TomoBEAR clone you have fetched. -## Standalone +### Standalone -TomoBEAR can also be used as a standalone application. For that you will need the standalone package itself which can be found on the [Releases page](https://github.com/KudryashevLab/tomoBEAR/releases). You have to download the zipped source code and the corresponding attached binary called `TomoBEAR`. Further you need to unzip archive with the source code and put in that folder downloaded `TomoBEAR` binary. +TomoBEAR can also be used as a standalone application. For that you will need to run the [installation script (see section above)](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#get-source-code-and-binary). +The available releases can be found on the [Releases page](https://github.com/KudryashevLab/TomoBEAR/releases). -As well, you will need to install and setup the additional software which is [mentioned below](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#additional-software). +As well, you will need to install and setup the external software which is [mentioned below](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#additional-software). Additionally you will need the MCR (MATLAB Compiled Runtime) from [here](https://www.mathworks.com/products/compiler/matlab-runtime.html). There you need to get the newest **MCR 2021a** to be able to run TomoBEAR. When the download of the MCR is finished you will need to give it execution rights. For that change to the folder where the file was downloaded to and execute the following command @@ -101,35 +143,56 @@ When the installation is finished, remember to include to the enviromental varia /usr/local/MATLAB/MATLAB_Runtime/v910/extern/bin/glnxa64 ``` -Inside of the cloned TomoBEAR folder you will find a "configurations" folder in which the file `defaults.json` can be found. Open the file `defaults.json` and adjust the following variables inside the `"general"` section: +Further you need to install TomoBEAR's dependencies, at least all mandatory ones: CUDA, Dynamo and IMOD. For the corresponding links and some instructions on that refer to the section [Additional Software](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#additional-software). -* `"pipeline_location": ""` put in the double quotes the location of cloned TomoBEAR -* `"motion_correction_command": ""` put in the double quotes the executable name of MotionCor2 or the full path (with the executable name) -* `"ctf_correction_command": ""` put in the double quotes the executable name of Gctf or the full path (with the executable name) -* `"dynamo_path": ""` put in the double quotes the path to your dynamo folder +Afterwards you need to configure and initialize TomoBEAR with the corresponding paths to the dependencies. Instructions on that part you may find below in the subsection [Configure installed software](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup#configure-installed-software) -Optionally you can set up as well the following variables inside the `"general"` section: +Finally, initialize the current TomoBEAR standalone by running (from TomoBEAR code directory) -* `"aretomo_command": ""` put in the double quotes the executable name of AreTomo or the full path (with the executable name) -* `"SUSAN_path": ""` put in the double quotes the location of cloned SUSAN +* `./TomoBEAR init` -If you use the Linux module system please insert the module names which need to be loaded to make all the necessary software available and working in the following variable in the general section +which will perform the initialization of necessary paths automatically, which could take a couple of minutes. But this you should do only once per the TomoBEAR clone you have fetched. -* `"modules": ["IMOD_module", "Gctf_module", "MotionCor2_module", "CUDA_module_1", "CUDA_module_2"]` +#### Configure installed software -Afterwards initialize the current TomoBEAR standalone by running (from TomoBEAR code directory) +Please, follow the setup instructions for all the software packages you downloaded. At the best, you will find the paths to the executables of the downloaded software in your `PATH` variable of your Linux system. -* `./TomoBEAR init` +If this is not the case you need to adjust the paths to the executables in the +`configurations/defaults.json` file. The keys where the values need to be adjusted can be found in the section `general` of the `defaults.json` file and are the following ones: +* mandatory: + - `"pipeline_location": ""` - location of the cloned TomoBEAR source code + - `"dynamo_path": ""` - path to your Dynamo folder +* semi-mandatory (if you need motion/CTF-correction routines): + - `"motion_correction_command": ""` - executable name of MotionCor2 or the full executable filepath + - `"ctf_correction_command": ""` - executable name of Gctf/CTFFIND4 or the full executable filepath +* optional: + - `"aretomo_command": ""` - executable name of AreTomo or the full executable filepath + - `"SUSAN_path": ""` - location of the cloned SUSAN source code + - `"conda_path": ""` - location of the anaconda/miniconda -which will perform the initialization of necessary paths automatically, which could take a couple of minutes. But this you should do only once per the TomoBEAR clone you have fetched. +Additionaly, to be able to use IsoNet, you need fill in the following variables in the section `IsoNet`: +* `"isonet_env": ""` - name of the environment created and configured for IsoNet (following the [IsoNet setup instructions](https://github.com/IsoNet-cryoET/IsoNet) ) +* `"repository_path": ""` - location of the cloned IsoNet source code + +> **Warning** +>
Be sure to use a version that supports your current CUDA installation. + +> **Note** +>
Sometimes software which depends on the newer CUDA libraries can handle versions compiled with older CUDA libraries. + +If you install IMOD the normal way then IMOD should be already in your `PATH` variable and therefore callable from everywhere. This is the only way of IMOD configuration supported by TomoBEAR. + +If you use the Linux module system please insert the module names which need to be loaded to make all the necessary software available and working in the following variable in the general section + +* `"modules": ["IMOD_module", "Gctf_module", "MotionCor2_module", "CUDA_module_1", "CUDA_module_2"]` ## Additional Software -As tomoBEAR is also wrapping standardized tools to fulfill some of the processing steps these need to be installed and executable. The advantage of such an Best of Breed approach is that you can profit of developments in algorithms in these tools and you can use them in the pipeline without any changes to the code at best. +As TomoBEAR is wrapping standardized tools to fulfill some of the processing steps these need to be installed and executable. ### Module System -If you are working in a cryo electron microscopy facility and employ a cluster with a module system where all the needed software is already deployed as modules it is fairly easy to setup tomoBEAR. If not all the software packages are available as modules you have two possibilities. +If you are working in a cryo electron microscopy facility and employ a cluster with a module system where all the needed software is already deployed as modules it is fairly easy to setup TomoBEAR. If not all the software packages are available as modules you have two possibilities. 1. The first and probably the easiest possibility for inexperienced users is to ask the administrator or some responsible person for the module system to introduce the needed software as modules @@ -143,7 +206,7 @@ As for the other software packages you can add the required CUDA versions also t The easiest way for the manual installation is to add the repositories with CUDA to your specific OS package manager. That is yum in CentOS and apt or apt-get in Ubuntu. The other way is a manual installation from the executables which are available from the [NVIDIA homepage](https://developer.nvidia.com/cuda-toolkit-archive). -#### CUDA +##### CUDA For all the additional software packages the proper CUDA toolkits with the newest driver for your graphics card need to be installed. @@ -161,11 +224,11 @@ To get the newest CUDA on an Ubuntu system the easiest way is to install it via #### Dynamo -For the non standalone version of tomoBEAR you need a Dynamo version with tilt stack alignment capabilities. The newest version can be downloaded from here. +For the non standalone version of TomoBEAR you need a Dynamo version with tilt stack alignment capabilities. The newest version can be [downloaded from here](https://wiki.dynamo.biozentrum.unibas.ch/w/index.php/Downloads). To minimize the dependencies on different CUDA versions it is advised to recompile the CUDA kernel for averaging with the newest CUDA version which is at best already available on your machine. If not please revise the chapter CUDA on this page. -To recompile the kernel you just need to the location where dynamo was extracted and access the folder ´cuda´ inside. There you will find a file called ´makefile´ which you need to open and modify the second line containing the variable ´CUDA_ROOT=´. Please put in there the path to your most recent CUDA release available on the system. +To recompile the kernel you just need to the location where dynamo was extracted and access the folder ```cuda``` inside. There you will find a file called ```makefile``` which you need to open and modify the second line containing the variable ```CUDA_ROOT=```. Please put in there the path to your most recent CUDA release available on the system. To recompile just execute the following two commands: @@ -181,12 +244,25 @@ MotionCor2 version greater than 1.4.0 is desired. - Alternative download [link](https://emcore.ucsf.edu/ucsf-software). -#### Gctf +#### AreTomo Head to the -[Gctf](https://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/zhang-software/) -downlaod page and download Gctf version 1.06. Gctf version 1.18 could -also work but is not tested. +[AreTomo](https://drive.google.com/drive/folders/1Z7pKVEdgMoNaUmd_cOFhlt-QCcfcwF3_) +download page. There you can find different AreTomo versions along with the documentation. + +#### Gctf + +You can download and try one of the following GCTF versions: +- [Gctf v1.06](https://www2.mrc-lmb.cam.ac.uk/download/gctf_v1-06-and-examples/) - the main version, tested to be working under TomoBEAR; +- [Gctf v1.18](https://www2.mrc-lmb.cam.ac.uk/download/special-version-for-phase-plate-gctf_v1-18/) - special version for phase plate data; +- [Gctf Gautomatch cu10.1](https://www2.mrc-lmb.cam.ac.uk/download/gctf_gautomatch_cu10-1-tar-gz/) - version for CUDA-10 (should work under TomoBEAR, but was not tested). + +#### CTFFIND4 + +Head to the [CTFFIND4](https://grigoriefflab.umassmed.edu/ctf_estimation_ctffind_ctftilt) or [cisTEM](https://cistem.org/) download page. There you can find CTFFIND4/cisTEM source code and/or binaries. + +> **Note** +>
In the following releases we are also planning to include CTFFIND4 updated version with tilted images support from the development version of the cisTEM package (https://cistem.org/development). #### IMOD @@ -200,38 +276,14 @@ To install and use SUSAN follow the instructions in the [SUSAN](https://github.c #### Anaconda -TomoBEAR can use various python based techniques to extend its functionality like using a neural net-based picker or a neural net-based denoising algorithm. For that, it assumes you have Anaconda or Miniconda installed. For that either use your OS-included package manager or install it from the [Anaconda](https://www.anaconda.com/products/individual) web page. You can also take the miniconda installation to save on space and inodes. - -#### CryoCARE - -CryoCARE is a neural net-based denoising framework based on convolutional neural nets and the u-net architecture which can learn to denoise cryo images. With TomoBEAR it is possible to denoise tomograms with the help of CryoCARE. To be able to do so it needs to be installed. For that please clone the [CryoCARE](https://github.com/juglab/cryoCARE_pip) implementation from [juglab](https://github.com/juglab) and follow the instructions on their page. - +TomoBEAR can use various python based techniques to extend its functionality like using a neural net-based picker, denoising or missing wedge reconstruction algorithm. For that, it assumes you have Anaconda or Miniconda installed. For that either use your OS-included package manager or install it from the [Anaconda](https://www.anaconda.com/products/individual) web page. You can also take the miniconda installation to save on space and inodes. +#### IsoNet -#### Software Installation +IsoNet is a DL framework based on convolutional neural nets (CNNs) and the U-net architecture which can learn both to denoise and reconstruct missing wedge on cryo-elecrtron microscopy images. With TomoBEAR it is possible to perform those operations on tomograms using IsoNet. For that please clone the [IsoNet](https://github.com/IsoNet-cryoET/IsoNet) and follow the instructions on their page to setup Python environment. -Please follow the instructions for all the software packages you -downloaded. At best you will find the paths to the executables of the -downloaded software in your `PATH` variable of your Linux system. If this -is not the case you need to adjust the paths to the executables in the -`defaults.json` file which you can find in the folder `configurations`. - -The keys where the values need to be adjusted can be found in the section `general` of the JSON file and are the following ones: - -* `"pipeline_location": ""` -* `"motion_correction_command": ""` -* `"ctf_correction_command": ""` -* `"dynamo_path": ""` - -If you don't have the software in your path you can provide the full -path to the executable as the value. Also if you downloaded a newer -version you will need to adjust the name of the executable even if you -can find it in the PATH variable. Also, be sure to use a version that -supports your current CUDA installation. Sometimes newer CUDA libraries -can handle versions compiled with older CUDA libraries. So it is worth -trying executables compiled for older CUDA libraries if you have newer -ones installed. - -If you install IMOD the normal way then IMOD should be already in your -`PATH` variable and therefore callable from everywhere. This is the only -way supported by TomoBEAR. +The original IsoNet version has limited missing wedge angular range of -60...+60, however there is an extended IsoNet version which allows for arbitrary parametrized missing wedge angular range on the ```mw_angle``` branch of the IsoNet original repository. TomoBEAR supports this version as well, so if you want to use it, you need to clone this branch by: +```bash +git clone --branch mw_angle https://github.com/IsoNet-cryoET/IsoNet.git IsoNet_mw +``` +where ```IsoNet_mw``` is the folder name where this IsoNet version will be cloned so that original IsoNet version is not overwritten if you already got one. diff --git a/wiki/Modules.md b/wiki/Modules.md index 65617ea..a9a4f34 100644 --- a/wiki/Modules.md +++ b/wiki/Modules.md @@ -1,17 +1,34 @@ -Following you can find descriptions of the functionality of the modules -and their parameters which can be setup in the json file in their -corresponding block. - -# General - -The general section is not a module but a section where all the general +# Modules +In this section you can find descriptions of the implemented modules, their functionality +and their parameters which can be setup in the JSON configuration file in their +corresponding blocks. + +## Contents +- [Global parameters configuration](#global-parameters-configuration) +- [Pipeline behavior control modules](#pipeline-behavior-control-modules) +- [CryoET data processing modules](#cryoet-data-processing-modules) +- [Template matching-associated modules](#template-matching-associated-modules) +- [Subtomogram Averaging modules](#subtomogram-averaging-modules) + +## Global parameters configuration + +### general +**Description** +
+The general section is not a module but a configuration section where all the general parameters regarding the processing and the environment can be found. -**Note:** Parameters which are input in this section are visible to all +**Parameters** +
+> **Note** +>
Parameters which are input in this section are visible to all modules during the execution. If parameters with the same key are found -in a modules block then they override parameters from the general +in a modules block then they override parameters from the "general" section. +
+ Parameters table (click to expand) + | Key | Default Value | Description | Examples | |------------------------------------------------------|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------| | gpu | -1 | defines the GPUs to use, -1 means take all GPUs, positive number takes one GPU, a combination of positive numbers in square brackets defines multiple GPUs to be used, 0 means no GPUs | -1, 2, \[1, 2, 3\] | @@ -134,6 +151,11 @@ section. | execute | true | this flag controls if the process function of an module is executed, this is set automatically to false for the cleanup functionality, normally you should not touch this flag | | | citation | "" | this variable holds the information for automatically generating the citations, **note** functionality is not fully implemented and tested | | +
+
+
+ Default parameters values (click to expand) + ```json "general": { "gpu": -1, @@ -257,14 +279,22 @@ section. "citation": "" } ``` +
+ +## Pipeline behavior control modules -# StopPipeline +### StopPipeline +**Description** +
The StopPipeline module is a module which controls the behavior of tomoBEAR. It allows to stop tomoBEAR after some processing step to inspect the output and not waste computational resources if parameters need to be optimized. +**Parameters** +
+ | Key | Default Value | Description | Examples | |------------------|---------------|---------------------------------------------------------------------------------------------------------------|----------| | execution_method | "control" | this variable defines the execution method for the module, **note** for this module it needs to be left as is | | @@ -275,11 +305,21 @@ need to be optimized. } ``` -# MetaData +## CryoET data processing modules +### MetaData +**Description** +
The MetaData module collects descriptive statistics such as min, max, mean, std from the raw data. +**Dependencies** +
+This module does not depend on any external packages. + +**Parameters** +
+ | Key | Default Value | Description | Examples | |--------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | execution_method | "control" | this variable defines the execution method for the module, **note** for this module it needs to be left as is | | @@ -300,11 +340,20 @@ mean, std from the raw data. } ``` -# SortFiles +### SortFiles +**Description** +
The SortFiles module sorts the raw files on a tomogram basis and links them to their corresponding folders for further processing. +**Dependencies** +
+This module does not depend on any external packages. + +**Parameters** +
+ | Key | Default Value | Description | Examples | |-------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | execution_method | "parallel" | this variable defines the execution method for the module, **note** for this module it needs to be left as is, except for debugging reasons you need to set it to "sequential" because MATLAB does only allow debugging of code in non parallel loops | | @@ -322,21 +371,28 @@ them to their corresponding folders for further processing. "fixed_number": 0, "skip": false, "citation": "" + } ``` -# MotionCor2 +### MotionCor2 + +**Description** +
+ +This module uses MotionCor2 to correct for the sample movement in a given projection can be a dose-fractionated movie or EER sequence. -The MotionCor2 module uses as the module's name suggests MotionCor2 to -correct for the sample movement in a given projection which is basically -a dose-fractionated movie. +For some of the options it is advised to look also into the original manual of MotionCor2 provided along with the source code as there are some more detailed descriptions. -For some of the options it is advised to look also into the manual of -MotionCor2 as there are some more detailed descriptions which you can -find -[here](https://docs.google.com/forms/d/e/1FAIpQLSfAQm5MA81qTx90W9JL6ClzSrM77tytsvyyHh1ZZWrFByhmfQ/viewform) -or [here](https://emcore.ucsf.edu/ucsf-software) when you download the -archive of MotionCor2. +**Dependencies** +
+- MotionCor2 +- IMOD +- CUDA (compatible with chosen MotionCor2 version, if GPU parallelization is needed) +**Parameters** +
+
+ Parameters table (click to expand) | Key | Default Value | Description | Examples | |-----------------------------------------------|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | method | "MotionCor2" | this variable defines the method to be used for frame based motion correction, **note** for this module it needs to be left as is, only MotionCor2 is supported at the moment | | @@ -374,6 +430,10 @@ archive of MotionCor2. | citation | "" | this variable holds the information for automatically generating the citations, **note** functionality is not fully implemented and tested | | | citation_link | "" | this variable holds the information for automatically generating the citations, **note** functionality is not fully implemented and tested | | | doi | "" | this variable holds the information for automatically generating the citations, **note** functionality is not fully implemented and tested | | +
+
+
+ Default parameters values (click to expand) ```json "MotionCor2": { @@ -414,8 +474,40 @@ archive of MotionCor2. "doi": "" } ``` +
+ +### GridEdgeEraser +**Description** +
+This module performs grid edge identification and erases it for Au grids data. -# CreateStacks +**Dependencies** +
+- Dynamo + +**Parameters** +
+```json + "GridEdgeEraser": { + "execution_method": "in_order", + "detection_binning": 4, + "grid_hole_diameter_in_um": 2, + "output_shift_user": [0, 0], + "output_shift_kernel_factor": [0, 0], + "binarize_threshold_in_std": 3, + "grid_detection_threshold_in_std": 3, + "smooth_mask_border": true, + "smooth_to_mean": true, + "smoothing_exp_decay": -40, + "cleaned_postfix": "gef", + "relink_as_previous_output": false + } +``` + +### CreateStacks + +**Description** +
The CreateStacks module creates the stacks and normalizes them. There are two options for normalization. The default normalization scheme is @@ -424,6 +516,14 @@ automatically if you are using high-dose images and divides them by their corresponding frame count in contrast to low-dose images where the frame-count is different. +**Dependencies** +
+- Dynamo +- IMOD + +**Parameters** +
+ | Key | Default Value | Description | Examples | |------------------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | execution_method | "in_order" | this variable defines the execution method for the module, if set to parallel out of memory errors can occur if you don't have enough memory, **note** for this module it needs to be left as is, except for debugging reasons you need to set it to "sequential" because MATLAB does only allow debugging of code in non parallel loops | | @@ -456,7 +556,10 @@ frame-count is different. } ``` -# DynamoTiltSeriesAlignment +### DynamoTiltSeriesAlignment + +**Description** +
The DynamoTiltSeriesAlignment module is using the tilt stacks alignment algorithm from dynamo which is the best available algorithm for @@ -465,6 +568,16 @@ ET projects are set. Some of them are dynamically derived. The option to override non-dynamically derived parameters is still available and can be done in the json configuration file. +**Dependencies** +
+- Dynamo + +**Parameters** +
+ +
+ Parameters table (click to expand) + | Key | Default Value | Description | Examples | |-------------------------------------------|-----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | execution_method | "parallel" | this variable defines the execution method for the module, if set to parallel out of memory errors can occur if you don't have enough memory, **note** for this module it needs to be left as is, except for debugging reasons you need to set it to "sequential" because MATLAB does only allow debugging of code in non parallel loops | | @@ -488,6 +601,11 @@ be done in the json configuration file. | citation_link | "" | this variable holds the information for automatically generating the citations, **note** functionality is not fully implemented and tested | | | doi | "" | this variable holds the information for automatically generating the citations, **note** functionality is not fully implemented and tested | | +
+
+
+ Default parameters values (click to expand) + ```json "DynamoTiltSeriesAlignment": { "execution_method": "parallel", @@ -599,15 +717,26 @@ be done in the json configuration file. "doi": "" } ``` +
-# DynamoCleanStacks +### DynamoCleanStacks +**Description** +
The DynamoCleanStacks module can be run after the DynamoTiltSeriesAlignment to automatically clean up the tilt stacks. For that **DynamoCleanStacks** uses the output from dynamo tilt stacks alignment which states on which projections the fiducials could be fit. The others are then removed from the tilt stacks for further processing. +**Dependencies** +
+- Dynamo +- IMOD + +**Parameters** +
+ | Key | Default Value | Description | Examples | |-----------------------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | execution_method | "parallel" | this variable defines the execution method for the module, if set to "parallel" out of memory errors can occur if you don't have enough memory, **note** for this module it needs to be left as is, except for debugging reasons you need to set it to "sequential" because MATLAB does only allow debugging of code in non parallel loops | | @@ -628,7 +757,46 @@ The others are then removed from the tilt stacks for further processing. } ``` -# BatchRunTomo +### AreTomo +**Description** +
+This module performs AreTomo-based fiducial-free alignment. + +**Dependencies** +
+- AreTomo +- IMOD +- CUDA (compatible with AreTomo) + +**Parameters** +
+ +```json + "AreTomo": { + "execution_method": "in_order", + "input_stack_binning": 1, + "reconstruction": false, + "weighted_back_projection": true, + "tilt_axis_refine_flag": 1, + "correct_tilt_axis_offset": 0, + "apply_given_tilt_axis_offset": false, + "tilt_axis_offset": 0, + "align_height_ratio": 0.75, + "apply_dose_weighting": false, + "sart": "20 5", + "roi": "0 0", + "roi_file": "", + "patch": "0 0", + "flip_volume": 1, + "flip_intensity": 0, + "citation": "" + } +``` + +### BatchRunTomo + +**Description** +
The BatchRunTomo module is the most versatile one as it can be setup to fulfill all the steps batchruntomo normally can do: @@ -658,6 +826,15 @@ fulfill all the steps batchruntomo normally can do: - 20: Post Processing with Trimvol - 21: NAD (Nonlinear anisotropic diffusion) +**Dependencies** +
+- IMOD + +**Parameters** +
+ +
+ Parameters table (click to expand) | Key | Default Value | Description | Examples | |----------------------------------------------------|---------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | execution_method | "parallel" | this variable defines the execution method for the module, if set to "parallel" out of memory errors can occur if you don't have enough memory, **note** for this module it needs to be left as is, except for debugging reasons you need to set it to "sequential" because MATLAB does only allow debugging of code in non parallel loops | | @@ -683,6 +860,10 @@ fulfill all the steps batchruntomo normally can do: The value "" means it will be automatically replaced by tomoBEAR and should not be replaced or changed by the user. +
+
+
+ Default parameters values (click to expand) ```json "BatchRunTomo": { @@ -797,13 +978,28 @@ tomoBEAR and should not be replaced or changed by the user. "doi": "" } ``` +
-# GCTFCtfphaseflipCTFCorrection +### GCTFCtfphaseflipCTFCorrection +**Description** +
The GCTFCtfphaseflipCTFCorrection module is detecting the CTF for the tomograms which are reconstructed for template matching or particle cropping. +**Dependencies** +
+- IMOD +- GCTF/CTFFIND4 +- CUDA (compatible with GCTF/CTFFIND4) + +**Parameters** +
+ +
+ Parameters table (click to expand) + | Key | Default Value | Description | Examples | |-----------------------------------|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | execution_method | "parallel" | this variable defines the execution method for the module, if set to "parallel" out of memory errors can occur if you don't have enough memory, **note** for this module it needs to be left as is, except for debugging reasons you need to set it to "sequential" because MATLAB does only allow debugging of code in non parallel loops | | @@ -833,6 +1029,12 @@ cropping. | citation_link | "" | this variable holds the information for automatically generating the citations, **note** functionality is not fully implemented and tested | | | doi | "" | this variable holds the information for automatically generating the citations, **note** functionality is not fully implemented and tested | | +
+ +
+
+ Default parameters values (click to expand) + ```json "GCTFCtfphaseflipCTFCorrection": { "execution_method": "parallel", @@ -863,13 +1065,22 @@ cropping. "doi": "" } ``` +
-# BinStacks - +### BinStacks +**Description** +
The BinStacks module is used for binning the stacks to be able to reconstruct them with the Reconstruct module which should be used after your stacks are binned. +**Dependencies** +
+- IMOD + +**Parameters** +
+ | Key | Default Value | Description | Examples | |---------------------------------|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | execution_method | "parallel" | this variable defines the execution method for the module, if set to "parallel" out of memory errors can occur if you don't have enough memory, **note** for this module it needs to be left as is, except for debugging reasons you need to set it to "sequential" because MATLAB does only allow debugging of code in non parallel loops | | @@ -886,23 +1097,26 @@ your stacks are binned. | doi | "" | this variable holds the information for automatically generating the citations, **note** functionality is not fully implemented and tested | | ```json - "BinStacks":{ + "BinStacks":{ "execution_method": "parallel", - "use_ctf_corrected_aligned_stack": true, - "antialias_filter": 6, - "defocus_tolerance": 20, - "iWidth": 2, + "use_ctf_corrected_aligned_stack": true, + "antialias_filter": 6, + "defocus_tolerance": 20, + "iWidth": 2, "ampContrast": 0.1, "run_ctf_phaseflip": false, - "ctf_corrected_stack_suffix": "ctfc", - "skip": false, + "ctf_corrected_stack_suffix": "ctfc", + "skip": false, "citation": "", - "citation_link": "", - "doi": "" + "citation_link": "", + "doi": "" } ``` -# Reconstruct +### Reconstruct + +**Description** +
The Reconstruct module should be used after you binned the tilt stacks with the BinStacks module or used aligned tilt stack binning option @@ -910,6 +1124,13 @@ greater than one. The module is set up by default to reconstruct binned stacks. If you otherwise want to reconstruct unbinned stacks you need to set up the Reconstruct module properly. +**Dependencies** +
+- IMOD + +**Parameters** +
+ | Key | Default Value | Description | Examples | |-----------------------------------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | execution_method | "parallel" | this variable defines the execution method for the module, if set to "parallel" out of memory errors can occur if you don't have enough memory, **note** for this module it needs to be left as is, except for debugging reasons you need to set it to "sequential" because MATLAB does only allow debugging of code in non parallel loops | | @@ -929,6 +1150,11 @@ set up the Reconstruct module properly. "use_ctf_corrected_stack": true, "generate_exact_filtered_tomograms": false, "exact_filter_size": 1500, + "generate_nad_filtered_tomograms": false, + "nad_filter_output_iterations_list": [3], + "nad_filter_number_of_iterations": -1, + "nad_filter_sigma_for_smoothing": -1, + "nad_filter_threshold_for_gradients": -1, "use_rawtlt": true, "correct_angles": "center", "skip": false, @@ -938,13 +1164,123 @@ set up the Reconstruct module properly. } ``` -# DynamoImportTomograms +### IsoNet + +**Description** +
+This module provides functionality of the IsoNet - DL framework for pre-processing, training and prediciton of restored information in the missing wedge region on the reconstructed cryo-elecrtron tomography volumes. + +**Dependencies** +
+- Anaconda +- IsoNet (and its Python dependencies) +- CUDA + +
+
+ Default parameters values (click to expand) + +```json +"IsoNet": { + "execution_method": "once", + "isonet_env": "", + "repository_path": "", + "tomograms_to_use": [], + "steps_to_execute": {}, + "steps_to_execute_defaults": { + "prepare_star": { + "use_ctf_corrected_tomograms": false, + "add_defocus_to_star": true, + "tomograms_binning": -1, + "folder_name": "tomograms", + "output_star": "tomograms.star", + "number_subtomos": -1 + }, + "deconv": { + "star_file": "tomograms.star", + "deconv_folder": "deconv", + "snrfalloff": 0.7, + "deconvstrength": -1, + "highpassnyquist": -1, + "chunk_size": -1, + "overlap_rate": -1, + "ncpu": -1 + }, + "make_mask": { + "star_file": "tomograms.star", + "mask_folder": "mask", + "patch_size": -1, + "mask_boundary": "", + "density_percentage": 50, + "std_percentage": 50, + "z_crop": -1, + "use_deconv_tomo": true + }, + "extract": { + "star_file": "tomograms.star", + "subtomo_folder": "subtomo", + "subtomo_star": "subtomo.star", + "cube_size": -1, + "crop_size": -1, + "use_deconv_tomo": true + }, + "refine": { + "subtomo_star": "subtomo.star", + "iterations": 30, + "data_dir": "", + "pretrained_model": "", + "result_dir": "results", + "preprocessing_ncpus": -1, + "continue_from": "", + "epochs": -1, + "batch_size": -1, + "steps_per_epoch": -1, + "noise_level": [0.05,0.1,0.15,0.2], + "noise_start_iter": [10,15,20,25], + "noise_mode": "", + "noise_dir": "", + "learning_rate": -1, + "drop_out": -1, + "convs_per_depth": -1, + "kernel": [], + "unet_depth": -1, + "filter_base": -1, + "batch_normalization": -1, + "normalize_percentile": -1 + }, + "predict": { + "star_file": "tomograms.star", + "model": "results/model_iter30.h5", + "output_dir": "corrected_tomos", + "cube_size": -1, + "crop_size": -1, + "batch_size": -1, + "normalize_percentile": -1 + } + } + } +``` +
+ + +## Template matching-associated modules +### DynamoImportTomograms + +**Description** +
The DynamoImportTomograms module generates a dynamo catalogue for you and inputs the tomograms to that catalogue. After that you can call the dynamo catalogue manager (dcm) to generate the models for the tomograms or pick in them particles by hand. +**Dependencies** +
+- Dynamo + +**Parameters** +
+ | Key | Default Value | Description | Examples | |------------------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | execution_method | "parallel" | this variable defines the execution method for the module, if set to "parallel" out of memory errors can occur if you don't have enough memory, **note** for this module it needs to be left as is, except for debugging reasons you need to set it to "sequential" because MATLAB does only allow debugging of code in non parallel loops | | @@ -964,14 +1300,24 @@ or pick in them particles by hand. "doi": "" } ``` -# EMDTemplateGeneration +### EMDTemplateGeneration + +**Description** +
The EMDTemplateGeneration module is used to automatically download a EMDB template which is further down-scaled to match your desired template matching binning. Besides that an automated routine to generate the mask is also implemented. This module needs to be run before template matching is executed. +**Dependencies** +
+- Dynamo + +**Parameters** +
+ ```json "EMDTemplateGeneration": { "execution_method": "once", @@ -993,8 +1339,19 @@ matching is executed. } ``` -# TemplateGenerationFromFile +### TemplateGenerationFromFile + +**Description** +
The concept of this module is the same as in EMDTemplateMatching, with the only difference of taking the template from a user-defined path instead of fetching it directly from EMDB. + +**Dependencies** +
+- Dynamo + +**Parameters** +
+ ```json "TemplateGenerationFromFile": { "execution_method": "once", @@ -1015,13 +1372,25 @@ The concept of this module is the same as in EMDTemplateMatching, with the only } ``` -# DynamoTemplateMatching +### DynamoTemplateMatching +**Description** +
The DynamoTemplateMatching module re-implements the template matching from Dynamo but on a GPU. Because of the GPU usage the whole thing runs up to 15 times faster than the normal template matching implementation of dynamo. +**Dependencies** +
+- Dynamo + +**Parameters** +
+ +
+ Default parameters values (click to expand) + ```json "DynamoTemplateMatching": { "execution_method": "in_order", @@ -1047,9 +1416,24 @@ implementation of dynamo. "citation": "" } ``` +
-# TemplateMatchingPostProcessing +### TemplateMatchingPostProcessing +**Description** +
This module creates Dynamo-like table of particles based on the results of the template matching procedure from the module DynamoTemplateMatching. As well, using this module you can extract subtomograms of the identified particles. + +**Dependencies** +
+- Dynamo +- SUSAN (if you chose it as the particles generation method) + +**Parameters** +
+ +
+ Default parameters values (click to expand) + ```json "TemplateMatchingPostProcessing": { "execution_method": "once", @@ -1088,9 +1472,60 @@ This module creates Dynamo-like table of particles based on the results of the t "citation": "" } ``` +
+ +## Subtomogram Averaging modules + +### GenerateParticles.m +**Description** +
+This module uses Dynamo-like particles table to either extract Dynamo-like particles from the tomogram or to crop SUSAN-like substacks and make from them particles reconstructions. -# DynamoAlignmentProject +**Dependencies** +
+- Dynamo +- SUSAN (if you chose it as the particles generation method) + +**Parameters** +
+ +
+ Default parameters values (click to expand) + +```json + "GenerateParticles": { + "execution_method": "once", + "generate_particles_method": "", + "particles_table_path": "", + "box_size": 1.0, + "particles_binning": -1, + "use_SUSAN": false, + "ctf_correction_method": "defocus_file", + "susan_padding": 200, + "per_particle_ctf_correction": "phase_flip", + "padding_policy": "zero", + "normalization": "zm" + } +``` +
+ + +### DynamoAlignmentProject + +**Description** +
This module is basically a wrapper for performing Dynamo alignment projects. + +**Dependencies** +
+- Dynamo +- SUSAN (if you chose it as the classification method) + +**Parameters** +
+
+ Default parameters values (click to expand) + ```json "DynamoAlignmentProject": { "randomize_angles": false, @@ -1134,58 +1569,58 @@ This module is basically a wrapper for performing Dynamo alignment projects. "classes": 0, "selected_classes": [], "sampling": 0, - "ite_r1": 0, - "nref_r1": 0, - "cone_range_r1": 0, - "cone_sampling_r1": 0, - "cone_flip_r1": 0, - "cone_check_peak_r1": 0, + "ite_r1": 0, + "nref_r1": 0, + "cone_range_r1": 0, + "cone_sampling_r1": 0, + "cone_flip_r1": 0, + "cone_check_peak_r1": 0, "cone_freeze_reference_r1": 0, - "inplane_range_r1": 0, - "inplane_sampling_r1": 0, - "inplane_flip_r1": 0, - "inplane_check_peak_r1": 0, - "inplane_freeze_reference_r1": 0, - "refine_r1": 0, - "refine_factor_r1": 0, - "high_r1": 0, - "low_r1": 0, - "sym_r1": 0, - "dim_r1": 0, + "inplane_range_r1": 0, + "inplane_sampling_r1": 0, + "inplane_flip_r1": 0, + "inplane_check_peak_r1": 0, + "inplane_freeze_reference_r1": 0, + "refine_r1": 0, + "refine_factor_r1": 0, + "high_r1": 0, + "low_r1": 0, + "sym_r1": 0, + "dim_r1": 0, "area_search_r1": 0, - "area_search_modus_r1": 0, - "separation_in_tomogram_r1": 0, - "limit_xy_check_peak_r1": 0, - "limit_z_check_peak_r1": 0, - "use_CC_r1": 0, - "localnc_r1": 0, - "mra_r1": 0, - "threshold_r1": 0, - "threshold_modus_r1": 0, - "threshold2_r1": 0, - "threshold2_modus_r1": 0, - "ccmatrix_r1": 0, - "ccmatrix_type_r1": 0, - "ccmatrix_batch_r1": 0, - "Xmatrix_r1": 0, - "Xmatrix_maxMb_r1": 0, - "PCA_r1": 0, - "PCA_neigs_r1": 0, - "kmeans_r1": "", - "kmeans_ncluster_r1": 0, - "kmeans_ncoefficients_r1": 0, - "nclass_r1": 0, - "plugin_align_r1": 0, - "plugin_post_r1": 0, - "plugin_iter_r1": 0, - "plugin_align_order_r1": 0, - "plugin_post_order_r1": 0, - "plugin_iter_order_r1": 0, - "flags_r1": 0, - "convergence_type_r1": 0, - "convergence_r1": 0, - "rings_r1": 0, - "rings_random_r1": 0, + "area_search_modus_r1": 0, + "separation_in_tomogram_r1": 0, + "limit_xy_check_peak_r1": 0, + "limit_z_check_peak_r1": 0, + "use_CC_r1": 0, + "localnc_r1": 0, + "mra_r1": 0, + "threshold_r1": 0, + "threshold_modus_r1": 0, + "threshold2_r1": 0, + "threshold2_modus_r1": 0, + "ccmatrix_r1": 0, + "ccmatrix_type_r1": 0, + "ccmatrix_batch_r1": 0, + "Xmatrix_r1": 0, + "Xmatrix_maxMb_r1": 0, + "PCA_r1": 0, + "PCA_neigs_r1": 0, + "kmeans_r1": "", + "kmeans_ncluster_r1": 0, + "kmeans_ncoefficients_r1": 0, + "nclass_r1": 0, + "plugin_align_r1": 0, + "plugin_post_r1": 0, + "plugin_iter_r1": 0, + "plugin_align_order_r1": 0, + "plugin_post_order_r1": 0, + "plugin_iter_order_r1": 0, + "flags_r1": 0, + "convergence_type_r1": 0, + "convergence_r1": 0, + "rings_r1": 0, + "rings_random_r1": 0, "dynamic_mask_r1": 0, "mask_path": "", "mask_apix": 1, @@ -1199,44 +1634,4 @@ This module is basically a wrapper for performing Dynamo alignment projects. "citation": "" } ``` - -# AreTomo -This module performs AreTomo-based fiducial-free alignment. -```json - "AreTomo": { - "execution_method": "in_order", - "reconstruction": false, - "weighted_back_projection": true, - "tilt_axis_refine_flag": 1, - "apply_tilt_axis_offset": 0, - "tilt_axis_offset": 0, - "align_height_ratio": 0.75, - "apply_dose_weighting": false, - "sart": "20 5", - "roi": "0 0", - "roi_file": "", - "patch": "0 0", - "flip_volume": 1, - "flip_intensity": 0, - "citation": "" - } -``` - -# GridEdgeEraser -This module performs grid edge identification and erases it for Au grids data. -```json - "GridEdgeEraser": { - "execution_method": "in_order", - "detection_binning": 4, - "grid_hole_diameter_in_um": 2, - "output_shift_user": [0, 0], - "output_shift_kernel_factor": [0, 0], - "binarize_threshold_in_std": 3, - "grid_detection_threshold_in_std": 3, - "smooth_mask_border": true, - "smooth_to_mean": true, - "smoothing_exp_decay": -40, - "cleaned_postfix": "gef", - "relink_as_previous_output": false - } -``` +
diff --git a/wiki/To-Do.md b/wiki/To-Do.md deleted file mode 100644 index a96f34c..0000000 --- a/wiki/To-Do.md +++ /dev/null @@ -1,23 +0,0 @@ -This page contains a collection of useful ideas and improvements to further facilitate processing. Please send us your ideas to mikhail.kudryashev at mdc-berlin.de - -# Mdoc-Files - -Mdoc-Files which are created by SerialEM contain a bunch of useful information. Therefore it is a good idea to make the most useful information from mdoc-files in the global configuration structure at best at the tomogram level available. As the tomogram acquisition schemes get more and more sophisticated it is good idea to capture the frame-dose and the frame count e.g. to parametrize later the parameters of MotionCor2 to properly dose weight the projections. - -There are two different formats of mdoc-files. The first format contains all the information for every projection in a single file whereas the other format contains all the information per project per file. - -# CryoCARE - -The CryoCARE module is a neural net based denoising framework. Beacuse it is a probabilistic - -# Template Matching - -Chose a binning level for template matching based on heuristics. If the GPU memory and performance grows further in the future it can be thought of incorporating this into the heuristics for chosing the proper binning level. - -# Stack Binning - -The process to generate binned stacks can be for some users confusing as you need to know when to generate them to save storage in the beginning of processing, at which binnings they need to be generated and what operations should be applied on them e.g. CTF correction or denoising. - -# GUI - -A web-based GUI will prove advantageous for workflow visualization and analysis of intermediate processing steps. \ No newline at end of file diff --git a/wiki/Tutorials.md b/wiki/Tutorials.md index f953bd1..7fc0345 100644 --- a/wiki/Tutorials.md +++ b/wiki/Tutorials.md @@ -1,23 +1,40 @@ -This page contains `TomoBEAR` tutorials which should showcase the capabilities of the processing pipeline. These tutorials assume that you have already cloned the [TomoBEAR github repository](https://github.com/KudryashevLab/TomoBEAR), installed all the required software and setup `TomoBEAR`. +# Tutorials +This page contains a range of tutorials explaining installation, setup, usage and example output to help you get started with ```TomoBEAR```. -# Ribosome (EMPIAR-10064) +## Setup TomoBEAR +First of all, you have to setup `TomoBEAR`: +* [Video-tutorial](https://drive.google.com/file/d/1Nhltdo7DbWdzPhAbnkzq7lCkDghxJrku/view?usp=share_link) explaining how to get the latest ```TomoBEAR``` version and configure ```TomoBEAR``` and its dependencies. -As a first data set to showcase the capabilities of `TomoBEAR` we have chosen the Ribosome data set with the number 10064 in the EMPIAR database. +## Ribosome (EMPIAR-10064) -You can get the data set from [here](https://www.ebi.ac.uk/empiar/EMPIAR-10064/). In our case we used just the `mixedCTEM` data and achieved 11.25 Å in resolution with ~4k particles which is similar to the resolution achieved by the original researchers. If you want you can additionally use the `CTEM` data to be able to pick even more particles. +To provide an example of the `TomoBEAR` processing project we have chosen the well-known cryo-ET benchmarking dataset containing 80S ribosomes - EMPIAR-10064. -After downloading the data extract it in a folder of your choice. One thing one should note about this data is that +In this tutorial we will: +* explain structure and important parameters of the input `JSON` file used as a configuration file in `TomoBEAR` projects; +* explain output data structure of `TomoBEAR` projects; +* explain pipeline execution and control by checkpoint files; +* guide you through the processing of the famous real-world dataset EMPIAR-10064 to achieve resolution of 11.25 Å with ~4k particles in nearly-automated parallelized manner. -* the data is already motion corrected -* the stacks are already assembled -* the pixel size is not in the header -* the tilt angles are not provided +### Download tutorial data -Because of such circumstances which sometimes occur `TomoBEAR` is able to inject this data along with the `JSON` file which describes the processing pipeline. +You can download EMPIAR-10064 dataset here (`mixedCTEM` part): . After downloading the data extract it in a folder of your choice. -If you have already cloned the [TomoBEAR github repository](https://github.com/KudryashevLab/TomoBEAR) to your local machine you can find in the configurations folder a file called `ribosome_empiar_10064_dynamo.json`. This file describes the processing pipeline which should be setup by `TomoBEAR` to process this data set. +In our case we used just the `mixedCTEM` data and achieved 11.25 Å in resolution with ~4k particles which is similar to the resolution achieved by the original researchers. If you want you can additionally use the `CTEM` data to be able to pick even more particles. -The following paragraphs will explain the variables contained in the `JSON` file and the needed changes to be able to run `TomoBEAR` on your local machine. In the end of this chapter the whole `JSON` file is shown. +### Video-tutorials + +We have prepared a range of short (8-12 min) video-tutorials following the written version of the 80S ribosome tutorial provided below: + +* [Video-tutoral 1](https://drive.google.com/file/d/12h8Vs4eUeJDJAb5S6nF2BuOX7lfvmmYo/view?usp=share_link): description of the project configuration file and the pipeline execution +* [Video-tutoral 2](https://drive.google.com/file/d/16nNdu89XUZglO_PiRKmGkK85o_nWqOB8/view?usp=share_link): additional configuration file parameters description, ```TomoBEAR```-```IMOD```-```TomoBEAR``` loop for checking tilt series alignment results and fiducials refinement (if needed); +* [Video-tutoral 3](https://drive.google.com/file/d/1t3ol3KlHqBGtnZp1bnLHi_Anurd2VPcx/view?usp=share_link): checking on further intermediate results (alignment, CTF-correction, reconstruction, template matching). + +### Setup configuration file + +In the `TomoBEAR` source code folder you will find a subfolder `configurations/` containing a file `ribosome_empiar_10064_dynamo.json`. This file describes the processing pipeline which should be setup by `TomoBEAR` to process used in this tutorial dataset. +The whole `JSON` file used for this tutorial you may also find at the end of this tutorial. + +The following paragraphs will explain the variables contained in the `JSON` file and the needed changes to be able to run `TomoBEAR` on your local machine. First of all and most importantly you need to show `TomoBEAR` the path to the data and the processing folder. This must be done in the section `"general": {}` of the `JSON` file. ```json @@ -38,6 +55,10 @@ First of all and most importantly you need to show `TomoBEAR` the path to the da }, ``` +Since the pixel size and tilt angles are not provided in the header of MRC files of the used here dataset EMPIAR-10064, we have to add this information in the `"general": {}` section of the configuration file. + +### Execute until fiducials refinement + Everything else should be fine for now and the processing can be started. To run the `TomoBEAR` on the Ribosome data set you need to type in the following command in the command window of MATLAB ```matlab @@ -68,9 +89,13 @@ When you followed all the steps thoroughly `TomoBEAR` should run up to the first "StopPipeline": { }, ``` -This can take a while, as the result of this segment `TomoBEAR` will create a folder structure with subfolders for the individual steps. You can monitor the progress of the execution in shell and by inspecting the contents of the folders. Upon success of an operation a file `SUCCESS` is written inside each folder. If you want to rerun a step you can terminate the process, change parameters, remove the `SUCCESS` file (or the entire subfolder) and restart the process. Here the stacks have already been assembled, so neither `"Motioncorr2": {}`, not `"SortFiles": {}` modules were not needed. Here the key functionality is performed by `"DynamoTiltSeriesAlignment": {}` (a recommended tutorial can be found [here](https://wiki.dynamo.biozentrum.unibas.ch/w/index.php/Walkthrough_on_GUI_based_tilt_series_alignment)) after which the projections containing low number of tracked gold beads are excluded by `"DynamoCleanStacks": {}`. Finally, the output is converted into an IMOD project. +This can take a while, as the result of this segment `TomoBEAR` will create a folder structure with subfolders for the individual steps. You can monitor the progress of the execution in shell and by inspecting the contents of the folders. Upon success of an operation a file `SUCCESS` is written inside each folder. If you want to rerun a step you can terminate the process, change parameters, remove the `SUCCESS` file (or the entire subfolder) and restart the process. + +Here the stacks have already been assembled, so neither `"Motioncorr2": {}`, not `"SortFiles": {}` modules were not needed. Here the key functionality is performed by `"DynamoTiltSeriesAlignment": {}` ([a recommended tutorial](https://wiki.dynamo.biozentrum.unibas.ch/w/index.php/Walkthrough_on_GUI_based_tilt_series_alignment)) after which the projections containing low number of tracked gold beads are excluded by `"DynamoCleanStacks": {}`. Finally, the output is converted into an IMOD project. The running time depends on your infrastructure and setup. + +### TomoBEAR-IMOD-TomoBEAR loop for fiducials refinement -The running time depends on your infrastructure and setup. After `TomoBEAR` stops you can inspect the fiducial model in the folder of `"BatchRunTomo": {}` which you can find in your processing folder. +After `TomoBEAR` stops you can inspect the fiducial model in the folder of `"BatchRunTomo": {}` which you can find in your processing folder. ```shell cd /path/to/your/processing/folder/5_BatchRunTomo_1 @@ -84,6 +109,8 @@ etomo tomogram_xxx/*.edf When `etomo` starts just chose the `fine alignment` step which should be Lila if everything went fine for that tomogram and then click on `edit/view fiducial model` to start `3dmod` with the right options to be able to refine the gold beads. Before you start to refine just press the arrow up button in the top left corner of the window with the view port. To refine the gold beads click on `Go to next big residual` in the window with the stacked buttons from top to bottom and the view in the view port window should change immediately to the location of a gold bead with a big residual. Now see if you can center the marker better on the gold bead with the right mouse button. It is important that you don't put it on the peak of the red arrow but center it on the gold bead. When you are finished with this gold bead just press again on the `Go to next big residual` button. After you are finished with re-centering the marker on the gold beads you need to press the `Save and run tiltalign` button. +### Execute up to tomogram reconstructions and template matching + After you finished the inspection of all the alignments you can start `TomoBEAR` again as previously and it will continue from where it stopped up to the next `StopPipeline` section. To continue running `TomoBEAR` on the Ribosome data set you need to type in as previously the following command in the command window of MATLAB @@ -132,6 +159,8 @@ This segment performs estimation of defocus, and hence, of the **Contrast Transf Then binned aligned CTF-corrected stacks are produced by `"BinStacks": {}` and tomographic reconstructions are generated for the binnings specified in the section `"general": {}`. In this example the particles are picked using template matching. First a template from EMDB is produced at a proper voxel size, then `"DynamoTemplateMatching": {}` creates **cross-correlation** (**CC**) volumes which can be inspected. Finally, highest cross-correlation peaks, over 2.5 standard deviations above the mean value in the cross-correlation volume are selected for extraction to 3D particle files, the initial coordinates are stored in the `particles_table` folder as a file in the dynamo table format. +### Execute subtomogram averaging (StA) + In the section below you will find **subtomogram classification projects** that should produce you a reasonable structure. They first use **multi-reference alignment projects** with a true class and so-called **noise trap classes** to first classify out false-positive particles produced by template matching, this happens at the binning which was used for template matching. In the end of the segment you should have a reasonable set of particles in the best class. ```json @@ -247,6 +276,7 @@ You may want to try to use the following example of the end section of `JSON` fi If you get `out of memory` error while running some of `"DynamoAlignmentProject": {}` at lower binnings (especially the last one), you may put additional parameter `"dt_crop_in_memory": 0` to the corresponding `"DynamoAlignmentProject": {}` sections in order to prevent keeping the whole tomogram in memory for processing. For example, in this tutorial size of the one of unbinned tomograms is ~72Gb, while for binning 2 it is near 9Gb. +### Estimate resolution of the output final map Finally, to estimate resolution of produced by `TomoBEAR` results, you need to use the following `Dynamo` command in `MATLAB`: ``` fsc = dfsc(path_to_half1, path_to_half2, 'apix', 2.62, 'mask', path_to_mask, 'show', 'on') @@ -260,12 +290,11 @@ After that you should get a similar FSC curve to the following one: where in Red we added a so-called "gold-standard" criterion of `FSC = 0.143` to estimate the final map resolution, which in our case for the final set of ~4k ribosome particles reached 11.25Å. +### Conclusion Here the Ribosome data set-based tutorial is finished. We thank you for trying out `TomoBEAR` and hope you have enjoyed it! -The full `JSON` file to setup the processing pipeline in `TomoBEAR` and process the data you may find -
-here (expand to see) +The full `JSON` configuration file to setup the processing pipeline and data in `TomoBEAR` (expand to see) ```json { @@ -417,11 +446,8 @@ The full `JSON` file to setup the processing pipeline in `TomoBEAR` and process ```
-
-or download it - here -# HIV1 (EMPIAR-10164) +## HIV1 (EMPIAR-10164) As the second data set to showcase the capabilities of `TomoBEAR` we have chosen the HIV-1 data set with the number 10164 in the EMPIAR database. diff --git a/wiki/Updates.md b/wiki/Updates.md deleted file mode 100644 index 4d95816..0000000 --- a/wiki/Updates.md +++ /dev/null @@ -1,2 +0,0 @@ -Sorry, the content of this page is not ready yet! -This page will be updated in the nearest future. diff --git a/wiki/Usage.md b/wiki/Usage.md index 41b350d..d2216e0 100644 --- a/wiki/Usage.md +++ b/wiki/Usage.md @@ -1,10 +1,107 @@ # TomoBEAR Configuration -If you followed the instructions thoroughly then you should have a -working copy of TomoBEAR. Now you need to generate a json file for your -project to start to process your acquired cryo EM data automated. +If you followed the [installation instructions](https://github.com/KudryashevLab/TomoBEAR/wiki/Installation-and-Setup) thoroughly then you should have a +working copy of the TomoBEAR. Now you need to generate a JSON file for your +project to start to process your acquired cryo-ET data. + +## Data entry + +### Input Data File Formats + +Generally, TomoBEAR supports the ```TIF(F)```, ```MRC``` and ```EER``` input data file formats. As well, for all of the formats TomoBEAR supports perception of the raw filenames for the data collected by different modes including: +- single-shot (conventional) - with a single-level TS numbering pattern; +- multi-shot (e.g. [PACEtomo](https://github.com/eisfabian/PACEtomo)) - with a two-level TS numbering pattern, including IDs of square and TS. + +**Table: Example cases of available input filenames recognition schemes** + +| Scenario | File Naming Patterns and Examples | +| ------------- | ------------- | +| Single-shot (conventional) frames (**TIF[F]/MRC**) | ```_{_}{_}{__