|
48 | 48 | import scyjava as sj
|
49 | 49 | import xarray as xr
|
50 | 50 | from jpype import JImplementationFor, setupGuiEnvironment
|
| 51 | +from jpype import __version__ as _jpype_version |
51 | 52 | from scyjava.config import find_jars
|
52 | 53 |
|
53 | 54 | import imagej.convert as convert
|
@@ -164,43 +165,83 @@ def argstring(self, args, ij1_style=True):
|
164 | 165 | formatted_args.append(arg)
|
165 | 166 | return " ".join(formatted_args)
|
166 | 167 |
|
167 |
| - def cite(self, show: bool = True) -> str: |
168 |
| - """Generate a citation string and package version numbers. |
| 168 | + def cite_publication(self, show: bool = True) -> str: |
| 169 | + """Generate a citation string. |
169 | 170 |
|
170 |
| - Generate the PyImageJ citation/reference string and fetch |
171 |
| - the environments Python and Java versions. |
| 171 | + Generate the PyImageJ citation/reference string. |
172 | 172 |
|
173 | 173 | :param show: Print the PyImageJ citation if True, if False
|
174 | 174 | the PyImageJ citation string is returned instead.
|
175 |
| - :return: A citation and package version numbers |
| 175 | + :return: The PyImageJ citation. |
176 | 176 | """
|
177 | 177 | # set PyImageJ reference sub strings
|
178 |
| - authors = "Rueden, C.T., Hiner, M.C., Evans, E.L. et al." |
| 178 | + header = "=====PyImageJ Citation=====" |
| 179 | + authors = "\nRueden, C.T., Hiner, M.C., Evans, E.L. et al." |
179 | 180 | pub_title = "\nPyImageJ: A library for integrating ImageJ and Python."
|
180 | 181 | journal = "\nNat Methods 19, 1326–1327 (2022)."
|
181 | 182 | doi_link = "\nhttps://doi.org/10.1038/s41592-022-01655-4"
|
182 |
| - divider = "\n-----------------------" |
183 |
| - # collect the current Python version |
184 |
| - py_vi = sys.version_info |
185 |
| - python_version = f"\nPython version: {py_vi.major}.{py_vi.minor}.{py_vi.micro}" |
186 |
| - # collect the current Java version |
187 |
| - j_vi = sj.jvm_version() |
188 |
| - java_version = f"\nJava version: {j_vi[0]}.{j_vi[1]}.{j_vi[2]}" |
189 |
| - # construct final string |
190 |
| - citation = ( |
191 |
| - authors |
192 |
| - + pub_title |
193 |
| - + journal |
194 |
| - + doi_link |
195 |
| - + divider |
196 |
| - + python_version |
197 |
| - + java_version |
198 |
| - ) |
| 183 | + |
| 184 | + # construct output citation string |
| 185 | + citation = header + authors + pub_title + journal + doi_link |
199 | 186 | if show:
|
200 | 187 | print(citation)
|
201 | 188 | else:
|
202 | 189 | return citation
|
203 | 190 |
|
| 191 | + def cite_versions(self, show: bool = True) -> str: |
| 192 | + """Fetch the current environment's package versions. |
| 193 | +
|
| 194 | + Fetch and construct the current environment's package versions. |
| 195 | + This function returns the versions for: |
| 196 | + - Python |
| 197 | + - Java |
| 198 | + - pyimagej |
| 199 | + - scyjava |
| 200 | + - imglyb |
| 201 | + - jgo |
| 202 | + - jpype |
| 203 | +
|
| 204 | + :param show: Print the PyImageJ citation if True, if False |
| 205 | + the PyImageJ citation string is returned instead. |
| 206 | + :param show: Print the version numbers if True, if False |
| 207 | + the environment version number string is returned instead. |
| 208 | + :return: The current PyImageJ instance's package versions. |
| 209 | + """ |
| 210 | + # collect the current isntance's package versions |
| 211 | + py_ver = sys.version_info |
| 212 | + java_ver = sj.jvm_version() |
| 213 | + pyimagej_ver = __version__ |
| 214 | + scyjava_ver = sj.get_version("scyjava") |
| 215 | + imglyb_ver = sj.get_version("imglyb") |
| 216 | + jpype_ver = _jpype_version |
| 217 | + jgo_ver = sj.get_version("jgo") |
| 218 | + |
| 219 | + # construct version strings |
| 220 | + header = "=====Environment package versions=====" |
| 221 | + python_ver_str = f"\nPython: {py_ver.major}.{py_ver.minor}.{py_ver.micro}" |
| 222 | + java_ver_str = f"\nJava: {java_ver[0]}.{java_ver[1]}.{java_ver[2]}" |
| 223 | + pyimagej_ver_str = f"\npyimagej: {pyimagej_ver}" |
| 224 | + scyjava_ver_str = f"\nscyjava: {scyjava_ver}" |
| 225 | + imglyb_ver_str = f"\nimglyb: {imglyb_ver}" |
| 226 | + jgo_ver_str = f"\njgo: {jgo_ver}" |
| 227 | + jpype_ver_str = f"\njpype: {jpype_ver}" |
| 228 | + |
| 229 | + # construct output version string |
| 230 | + versions = ( |
| 231 | + header |
| 232 | + + python_ver_str |
| 233 | + + java_ver_str |
| 234 | + + pyimagej_ver_str |
| 235 | + + scyjava_ver_str |
| 236 | + + imglyb_ver_str |
| 237 | + + jgo_ver_str |
| 238 | + + jpype_ver_str |
| 239 | + ) |
| 240 | + if show: |
| 241 | + print(versions) |
| 242 | + else: |
| 243 | + return versions |
| 244 | + |
204 | 245 | def dtype(self, image_or_type):
|
205 | 246 | """Get the dtype of the input image as a numpy.dtype object.
|
206 | 247 |
|
|
0 commit comments