Skip to content
Snippets Groups Projects
Commit 79da814f authored by fima's avatar fima :beers:
Browse files

Doi reference system

parent b19d3cd4
No related branches found
No related tags found
1 merge request!18Doi reference system
%% Cell type:markdown id:ac0524be tags:
# Get references from DOI
THis notebook shows hos it is possible to use the Qim3D library to easily get well formatted references from a DOI
%% Cell type:code id:7e71f00d tags:
``` python
import qim3d
qim3d.io.logger.level('info')
```
%% Cell type:code id:ec92ed5f tags:
``` python
doi = "https://doi.org/10.1007/s10851-021-01041-3"
```
%% Cell type:code id:87ba2542 tags:
``` python
bibtext = qim3d.utils.doi.get_bibtex(doi)
```
%% Output
@article{Stephensen_2021,
doi = {10.1007/s10851-021-01041-3},
url = {https://doi.org/10.1007%2Fs10851-021-01041-3},
year = 2021,
month = {jun},
publisher = {Springer Science and Business Media {LLC}},
volume = {63},
number = {8},
pages = {1069--1083},
author = {Hans J. T. Stephensen and Anne Marie Svane and Carlos B. Villanueva and Steven A. Goldman and Jon Sporring},
title = {Measuring Shape Relations Using r-Parallel Sets},
journal = {Journal of Mathematical Imaging and Vision}
}
%% Cell type:code id:5a4dcf74 tags:
``` python
reference = qim3d.utils.doi.get_reference(doi)
```
%% Output
Stephensen, H. J. T., Svane, A. M., Villanueva, C. B., Goldman, S. A., & Sporring, J. (2021). Measuring Shape Relations Using r-Parallel Sets. Journal of Mathematical Imaging and Vision, 63(8), 1069–1083. https://doi.org/10.1007/s10851-021-01041-3
%% Cell type:code id:1fb81ae4 tags:
``` python
qim3d.utils.doi.get_metadata(doi)
```
%% Output
{'indexed': {'date-parts': [[2023, 9, 21]],
'date-time': '2023-09-21T13:58:37Z',
'timestamp': 1695304717010},
'reference-count': 26,
'publisher': 'Springer Science and Business Media LLC',
'issue': '8',
'license': [{'start': {'date-parts': [[2021, 6, 26]],
'date-time': '2021-06-26T00:00:00Z',
'timestamp': 1624665600000},
'content-version': 'tdm',
'delay-in-days': 0,
'URL': 'https://www.springer.com/tdm'},
{'start': {'date-parts': [[2021, 6, 26]],
'date-time': '2021-06-26T00:00:00Z',
'timestamp': 1624665600000},
'content-version': 'vor',
'delay-in-days': 0,
'URL': 'https://www.springer.com/tdm'}],
'funder': [{'DOI': '10.13039/100008398',
'name': 'Villum Fonden',
'doi-asserted-by': 'publisher'},
{'DOI': '10.13039/501100005275',
'name': 'Region Hovedstaden',
'doi-asserted-by': 'publisher'}],
'content-domain': {'domain': ['link.springer.com'],
'crossmark-restriction': False},
'published-print': {'date-parts': [[2021, 10]]},
'DOI': '10.1007/s10851-021-01041-3',
'type': 'journal-article',
'created': {'date-parts': [[2021, 6, 26]],
'date-time': '2021-06-26T15:02:20Z',
'timestamp': 1624719740000},
'page': '1069-1083',
'update-policy': 'http://dx.doi.org/10.1007/springer_crossmark_policy',
'source': 'Crossref',
'is-referenced-by-count': 3,
'title': 'Measuring Shape Relations Using r-Parallel Sets',
'prefix': '10.1007',
'volume': '63',
'author': [{'ORCID': 'http://orcid.org/0000-0001-8245-0571',
'authenticated-orcid': False,
'given': 'Hans J. T.',
'family': 'Stephensen',
'sequence': 'first',
'affiliation': []},
{'ORCID': 'http://orcid.org/0000-0001-6356-0484',
'authenticated-orcid': False,
'given': 'Anne Marie',
'family': 'Svane',
'sequence': 'additional',
'affiliation': []},
{'ORCID': 'http://orcid.org/0000-0001-9786-9439',
'authenticated-orcid': False,
'given': 'Carlos B.',
'family': 'Villanueva',
'sequence': 'additional',
'affiliation': []},
{'ORCID': 'http://orcid.org/0000-0002-5498-4303',
'authenticated-orcid': False,
'given': 'Steven A.',
'family': 'Goldman',
'sequence': 'additional',
'affiliation': []},
{'ORCID': 'http://orcid.org/0000-0003-1261-6702',
'authenticated-orcid': False,
'given': 'Jon',
'family': 'Sporring',
'sequence': 'additional',
'affiliation': []}],
'member': '297',
'published-online': {'date-parts': [[2021, 6, 26]]},
'reference': [{'key': '1041_CR1',
'doi-asserted-by': 'publisher',
'volume-title': 'Spatial Point Patterns: Methodology and Applications with R',
'author': 'A Baddeley',
'year': '2015',
'unstructured': 'Baddeley, A., Rubak, E., Turner, R.: Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton (2015)',
'DOI': '10.1201/b19708'},
{'key': '1041_CR2',
'series-title': 'Statistics Reference Online',
'doi-asserted-by': 'publisher',
'DOI': '10.1002/9781118445112.stat07751',
'volume-title': 'Ripley’s $$k$$ Function',
'author': 'PM Dixon',
'year': '2014',
'unstructured': 'Dixon, P.M.: Ripley’s $$k$$ Function. Statistics Reference Online, Wiley, New York (2014)'},
{'issue': '1',
'key': '1041_CR3',
'doi-asserted-by': 'publisher',
'first-page': '1',
'DOI': '10.1016/0962-8924(94)90025-6',
'volume': '4',
'author': 'R Fesce',
'year': '1994',
'unstructured': 'Fesce, R., Grohovaz, F., Valtorta, F., Meldolesi, J.: Neurotransmitter release: fusion or kiss-and-run? Trends Cell Biol. 4(1), 1–4 (1994)',
'journal-title': 'Trends Cell Biol.'},
{'issue': '8',
'key': '1041_CR4',
'doi-asserted-by': 'publisher',
'first-page': '1953',
'DOI': '10.1007/s00138-014-0625-2',
'volume': '25',
'author': 'Y Gavet',
'year': '2014',
'unstructured': 'Gavet, Y., Fernandes, M., Debayle, J., Pinoli, J.C.: Dissimilarity criteria and their comparison for quantitative evaluation of image segmentation: application to human retina vessels. Mach. Vis. Appl. 25(8), 1953–1966 (2014)',
'journal-title': 'Mach. Vis. Appl.'},
{'key': '1041_CR5',
'doi-asserted-by': 'publisher',
'first-page': '248',
'DOI': '10.3389/fncel.2018.00248',
'volume': '12',
'author': 'N Gavrilov',
'year': '2018',
'unstructured': 'Gavrilov, N., Golyagina, I., Brazhe, A., Scimemi, A., Turlapov, V., Semyanov, A.: Astrocytic coverage of dendritic spines, dendritic shafts, and axonal boutons in hippocampal neuropil. Front. Cell. Neurosci. 12, 248 (2018)',
'journal-title': 'Front. Cell. Neurosci.'},
{'issue': '498',
'key': '1041_CR6',
'doi-asserted-by': 'publisher',
'first-page': '754',
'DOI': '10.1080/01621459.2012.688463',
'volume': '107',
'author': 'U Hahn',
'year': '2012',
'unstructured': 'Hahn, U.: A studentized permutation test for the comparison of spatial point patterns. J. Am. Stat. Assoc. 107(498), 754–764 (2012). https://doi.org/10.1080/01621459.2012.688463',
'journal-title': 'J. Am. Stat. Assoc.'},
{'issue': '4',
'key': '1041_CR7',
'doi-asserted-by': 'publisher',
'first-page': '60:1',
'DOI': '10.1145/3197517.3201353',
'volume': '37',
'author': 'Y Hu',
'year': '2018',
'unstructured': 'Hu, Y., Zhou, Q., Gao, X., Jacobson, A., Zorin, D., Panozzo, D.: Tetrahedral meshing in the wild. ACM Trans. Gr. 37(4), 60:1-60:14 (2018). https://doi.org/10.1145/3197517.3201353',
'journal-title': 'ACM Trans. Gr.'},
{'key': '1041_CR8',
'doi-asserted-by': 'publisher',
'unstructured': 'Khanmohammadi, M., Waagepetersen, R.P., Sporring, J.: Analysis of shape and spatial interaction of synaptic vesicles using data from focused ion beam scanning electron microscopy (FIB-SEM). Front. Neuroanatomy (2015). https://doi.org/10.3389/fnana.2015.00116',
'DOI': '10.3389/fnana.2015.00116'},
{'issue': '3',
'key': '1041_CR9',
'doi-asserted-by': 'publisher',
'first-page': '797',
'DOI': '10.1083/jcb.135.3.797',
'volume': '135',
'author': 'J Koenig',
'year': '1996',
'unstructured': 'Koenig, J., Ikeda, K.: Synaptic vesicles have two distinct recycling pathways. J. Cell Biol. 135(3), 797–808 (1996)',
'journal-title': 'J. Cell Biol.'},
{'key': '1041_CR10',
'unstructured': 'Lucchi, A., Li, Y., Becker, C., Fua, P.: Electron microscopy dataset. https://cvlab.epfl.ch/data/data-em/. Accessed 14 Mar 2020'},
{'issue': '2',
'key': '1041_CR11',
'doi-asserted-by': 'publisher',
'first-page': '568',
'DOI': '10.1002/mrm.24477',
'volume': '70',
'author': 'J Marques',
'year': '2013',
'unstructured': 'Marques, J., Genant, H.K., Lillholm, M., Dam, E.B.: Diagnosis of osteoarthritis and prognosis of tibial cartilage loss by quantification of tibia trabecular bone from MRI. Magn. Reson. Med. 70(2), 568–575 (2013). https://doi.org/10.1002/mrm.24477',
'journal-title': 'Magn. Reson. Med.'},
{'issue': '1654',
'key': '1041_CR12',
'doi-asserted-by': 'publisher',
'first-page': '20140047',
'DOI': '10.1098/rstb.2014.0047',
'volume': '369',
'author': 'N Medvedev',
'year': '2014',
'unstructured': 'Medvedev, N., Popov, V., Henneberger, C., Kraev, I., Rusakov, D.A., Stewart, M.G.: Glia selectively approach synapses on thin dendritic spines. Philos. Trans. R Soc. B Biol. Sci. 369(1654), 20140047 (2014)',
'journal-title': 'Philos. Trans. R Soc. B Biol. Sci.'},
{'issue': '3',
'key': '1041_CR13',
'doi-asserted-by': 'publisher',
'first-page': '551',
'DOI': '10.1016/S0896-6273(00)00065-9',
'volume': '27',
'author': 'D Richards',
'year': '2000',
'unstructured': 'Richards, D., Guatimosim, C., Betz, W.: Two endocytic recycling routes selectively fill two vesicle pools in frog motor nerve terminals. Neuron 27(3), 551–559 (2000)',
'journal-title': 'Neuron'},
{'issue': '3',
'key': '1041_CR14',
'doi-asserted-by': 'publisher',
'first-page': '368',
'DOI': '10.1111/j.2517-6161.1979.tb01091.x',
'volume': '41',
'author': 'BD Ripley',
'year': '1979',
'unstructured': 'Ripley, B.D.: Tests of randomness for spatial point patterns. J. Roy. Stat. Soc. Ser. B (Methodol.) 41(3), 368–374 (1979). https://doi.org/10.1111/j.2517-6161.1979.tb01091.x',
'journal-title': 'J. Roy. Stat. Soc. Ser. B (Methodol.)'},
{'key': '1041_CR15',
'doi-asserted-by': 'publisher',
'volume-title': 'Statistical Inference for Spatial Processes',
'author': 'BD Ripley',
'year': '1988',
'unstructured': 'Ripley, B.D.: Statistical Inference for Spatial Processes. Cambridge University Press, Cambridge (1988)',
'DOI': '10.1017/CBO9780511624131'},
{'key': '1041_CR16',
'doi-asserted-by': 'crossref',
'unstructured': 'Ronneberger, O., Fischer, P., Brox, T.: U-net: convolutional networks for biomedical image segmentation. In: International Conference on Medical Image Computing and Computer-Assisted Intervention, pp. 234–241. Springer (2015)',
'DOI': '10.1007/978-3-319-24574-4_28'},
{'key': '1041_CR17',
'doi-asserted-by': 'publisher',
'volume-title': 'Stochastic and Integral Geometry',
'author': 'R Schneider',
'year': '2008',
'unstructured': 'Schneider, R., Weil, W.: Stochastic and Integral Geometry. Springer, Heidelberg (2008)',
'DOI': '10.1007/978-3-540-78859-1'},
{'key': '1041_CR18',
'unstructured': 'Scientific, T.F.: Amira-avizo software (2020)'},
{'key': '1041_CR19',
'doi-asserted-by': 'crossref',
'unstructured': 'Sethian, J.A.: Fast marching methods. SIAM Rev. 41(2), 199–235 (1999)',
'DOI': '10.1137/S0036144598347059'},
{'issue': '2',
'key': '1041_CR20',
'doi-asserted-by': 'publisher',
'first-page': '1',
'DOI': '10.1145/2629697',
'volume': '41',
'author': 'H Si',
'year': '2015',
'unstructured': 'Si, H.: TetGen, a delaunay-based quality tetrahedral mesh generator. ACM Trans. Math. Softw. 41(2), 1–36 (2015)',
'journal-title': 'ACM Trans. Math. Softw.'},
{'key': '1041_CR21',
'doi-asserted-by': 'crossref',
'unstructured': 'Sporring, J., Waagepetersen, R., Sommer, S.: Generalizations of Ripley’s k-function with application to space curves. In: International Conference on Information Processing in Medical Imaging, pp. 731–742. Springer (2019)',
'DOI': '10.1007/978-3-030-20351-1_57'},
{'issue': '1',
'key': '1041_CR22',
'doi-asserted-by': 'publisher',
'first-page': '1',
'DOI': '10.1038/s42003-020-0809-4',
'volume': '3',
'author': 'HJT Stephensen',
'year': '2020',
'unstructured': 'Stephensen, H.J.T., Darkner, S., Sporring, J.: Restoring drifted electron microscope volumes using synaptic vesicles at sub-pixel accuracy. Commun. Biol. 3(1), 1–7 (2020)',
'journal-title': 'Commun. Biol.'},
{'key': '1041_CR23',
'unstructured': 'Stephensen, H.J.T., Sporring, J.: Rodent neuronal volume annotations and segmentations (2020). https://www.doi.org/10.17894/ucph.33bd30d2-5796-48f4-a0a8-96fcc0ce6af5'},
{'key': '1041_CR24',
'doi-asserted-by': 'crossref',
'unstructured': 'Svane, A.M.: Valuations in image analysis. In: Tensor Valuations and Their Applications in Stochastic Geometry and Imaging, pp. 435–454. Springer (2017)',
'DOI': '10.1007/978-3-319-51951-7_15'},
{'key': '1041_CR25',
'doi-asserted-by': 'publisher',
'unstructured': 'Virtanen, P., Gommers, R., Oliphant, T.E., Haberland, M., Reddy, T., Cournapeau, D., Burovski, E., Peterson, P., Weckesser, W., Bright, J., van der Walt, S.J., Brett, M., Wilson, J., Jarrod Millman, K., Mayorov, N., Nelson, A.R.J., Jones, E., Kern, R., Larson, E., Carey, C., Polat, İ, Feng, Y., Moore, E.W., Van der Plas, J., Laxalde, D., Perktold, J., Cimrman, R., Henriksen, I., Quintero, E.A., Harris, C.R., Archibald, A.M., Ribeiro, A.H., Pedregosa, F., van Mulbregt, P., Contributors, S., et al.: SciPy 1.0: fundamental algorithms for scientific computing in python. Nat. Methods 17, 261–272 (2020). https://doi.org/10.1038/s41592-019-0686-2',
'DOI': '10.1038/s41592-019-0686-2'},
{'issue': '1',
'key': '1041_CR26',
'doi-asserted-by': 'publisher',
'first-page': '1',
'DOI': '10.1016/j.patcog.2003.07.008',
'volume': '37',
'author': 'D Zhang',
'year': '2004',
'unstructured': 'Zhang, D., Lu, G.: Review of shape representation and description techniques. Pattern Recogn. 37(1), 1–19 (2004). https://doi.org/10.1016/j.patcog.2003.07.008',
'journal-title': 'Pattern Recogn.'}],
'container-title': 'Journal of Mathematical Imaging and Vision',
'original-title': [],
'language': 'en',
'link': [{'URL': 'https://link.springer.com/content/pdf/10.1007/s10851-021-01041-3.pdf',
'content-type': 'application/pdf',
'content-version': 'vor',
'intended-application': 'text-mining'},
{'URL': 'https://link.springer.com/article/10.1007/s10851-021-01041-3/fulltext.html',
'content-type': 'text/html',
'content-version': 'vor',
'intended-application': 'text-mining'},
{'URL': 'https://link.springer.com/content/pdf/10.1007/s10851-021-01041-3.pdf',
'content-type': 'application/pdf',
'content-version': 'vor',
'intended-application': 'similarity-checking'}],
'deposited': {'date-parts': [[2023, 1, 1]],
'date-time': '2023-01-01T16:48:24Z',
'timestamp': 1672591704000},
'score': 1,
'resource': {'primary': {'URL': 'https://link.springer.com/10.1007/s10851-021-01041-3'}},
'subtitle': [],
'short-title': [],
'issued': {'date-parts': [[2021, 6, 26]]},
'references-count': 26,
'journal-issue': {'issue': '8',
'published-print': {'date-parts': [[2021, 10]]}},
'alternative-id': ['1041'],
'URL': 'http://dx.doi.org/10.1007/s10851-021-01041-3',
'relation': {},
'ISSN': ['0924-9907', '1573-7683'],
'subject': ['Applied Mathematics',
'Geometry and Topology',
'Computer Vision and Pattern Recognition',
'Condensed Matter Physics',
'Modeling and Simulation',
'Statistics and Probability'],
'container-title-short': 'J Math Imaging Vis',
'published': {'date-parts': [[2021, 6, 26]]},
'assertion': [{'value': '7 November 2020',
'order': 1,
'name': 'received',
'label': 'Received',
'group': {'name': 'ArticleHistory', 'label': 'Article History'}},
{'value': '2 June 2021',
'order': 2,
'name': 'accepted',
'label': 'Accepted',
'group': {'name': 'ArticleHistory', 'label': 'Article History'}},
{'value': '26 June 2021',
'order': 3,
'name': 'first_online',
'label': 'First Online',
'group': {'name': 'ArticleHistory', 'label': 'Article History'}},
{'order': 1,
'name': 'Ethics',
'group': {'name': 'EthicsHeading', 'label': 'Declarations'}},
{'value': 'The authors declare that they have no conflict of interest.',
'order': 2,
'name': 'Ethics',
'group': {'name': 'EthicsHeading', 'label': 'Conflict of interest'}}]}
...@@ -197,7 +197,7 @@ ...@@ -197,7 +197,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.9.11" "version": "3.10.11"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
import qim3d
doi = "https://doi.org/10.1007/s10851-021-01041-3"
def test_get_bibtex():
bibtext = qim3d.utils.doi.get_bibtex(doi)
assert (
bibtext
== "@article{Stephensen_2021,\n\tdoi = {10.1007/s10851-021-01041-3},\n\turl = {https://doi.org/10.1007%2Fs10851-021-01041-3},\n\tyear = 2021,\n\tmonth = {jun},\n\tpublisher = {Springer Science and Business Media {LLC}},\n\tvolume = {63},\n\tnumber = {8},\n\tpages = {1069--1083},\n\tauthor = {Hans J. T. Stephensen and Anne Marie Svane and Carlos B. Villanueva and Steven A. Goldman and Jon Sporring},\n\ttitle = {Measuring Shape Relations Using r-Parallel Sets},\n\tjournal = {Journal of Mathematical Imaging and Vision}\n}"
)
def test_get_reference():
reference = qim3d.utils.doi.get_reference(doi)
assert (
reference
== "Stephensen, H. J. T., Svane, A. M., Villanueva, C. B., Goldman, S. A., & Sporring, J. (2021). Measuring Shape Relations Using r-Parallel Sets. Journal of Mathematical Imaging and Vision, 63(8), 1069â\x80\x931083. https://doi.org/10.1007/s10851-021-01041-3\n"
)
...@@ -2,3 +2,5 @@ from . import internal_tools ...@@ -2,3 +2,5 @@ from . import internal_tools
from .models import train_model, model_summary, inference from .models import train_model, model_summary, inference
from .augmentations import Augmentation from .augmentations import Augmentation
from .data import Dataset, prepare_datasets, prepare_dataloaders from .data import Dataset, prepare_datasets, prepare_dataloaders
#from .doi import get_bibtex, get_reference
from . import doi
\ No newline at end of file
""" Deals with DOI for references """
import json
import requests
from qim3d.io.logger import log
def _validate_response(response):
# Check if we got a good response
if not response.ok:
log.error(f"Could not read the provided DOI ({response.reason})")
return False
return True
def _doi_to_url(doi):
if doi[:3] != "http":
url = "https://doi.org/" + doi
else:
url = doi
return url
def _make_request(doi, header):
# Get url from doi
url = _doi_to_url(doi)
# run the request
response = requests.get(url, headers=header, timeout=10)
if not _validate_response(response):
return None
return response
def _log_and_get_text(doi, header):
response = _make_request(doi, header)
if response:
text = response.text
log.info(text)
return text
def get_bibtex(doi):
"""Generates bibtex from doi"""
header = {"Accept": "application/x-bibtex"}
return _log_and_get_text(doi, header)
def get_reference(doi):
"""Generates basic reference from doi"""
header = {"Accept": "text/bibliography"}
return _log_and_get_text(doi, header)
def cusom_header(doi, header):
"""Allows a custom header to be passed
For example:
doi = "https://doi.org/10.1101/2022.11.08.515664"
header = {"Accept": "text/bibliography"}
response = qim3d.utils.doi.cusom_header(doi, header)
"""
return _log_and_get_text(doi, header)
def get_metadata(doi):
"""Generates a metadata dictionary from doi"""
header = {"Accept": "application/vnd.citationstyles.csl+json"}
response = _make_request(doi, header)
metadata = json.loads(response.text)
return metadata
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment