id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
17,600
Kozea/cairocffi
cairocffi/context.py
Context.tag_begin
def tag_begin(self, tag_name, attributes=None): """Marks the beginning of the ``tag_name`` structure. Call :meth:`tag_end` with the same ``tag_name`` to mark the end of the structure. The attributes string is of the form "key1=value2 key2=value2 ...". Values may be boolean (tru...
python
def tag_begin(self, tag_name, attributes=None): """Marks the beginning of the ``tag_name`` structure. Call :meth:`tag_end` with the same ``tag_name`` to mark the end of the structure. The attributes string is of the form "key1=value2 key2=value2 ...". Values may be boolean (tru...
[ "def", "tag_begin", "(", "self", ",", "tag_name", ",", "attributes", "=", "None", ")", ":", "if", "attributes", "is", "None", ":", "attributes", "=", "''", "cairo", ".", "cairo_tag_begin", "(", "self", ".", "_pointer", ",", "_encode_string", "(", "tag_name...
Marks the beginning of the ``tag_name`` structure. Call :meth:`tag_end` with the same ``tag_name`` to mark the end of the structure. The attributes string is of the form "key1=value2 key2=value2 ...". Values may be boolean (true/false or 1/0), integer, float, string, or an arra...
[ "Marks", "the", "beginning", "of", "the", "tag_name", "structure", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L2198-L2240
17,601
Kozea/cairocffi
cairocffi/context.py
Context.tag_end
def tag_end(self, tag_name): """Marks the end of the ``tag_name`` structure. Invalid nesting of tags will cause @cr to shutdown with a status of ``CAIRO_STATUS_TAG_ERROR``. See :meth:`tag_begin`. :param tag_name: tag name *New in cairo 1.16.* *New in cairocff...
python
def tag_end(self, tag_name): """Marks the end of the ``tag_name`` structure. Invalid nesting of tags will cause @cr to shutdown with a status of ``CAIRO_STATUS_TAG_ERROR``. See :meth:`tag_begin`. :param tag_name: tag name *New in cairo 1.16.* *New in cairocff...
[ "def", "tag_end", "(", "self", ",", "tag_name", ")", ":", "cairo", ".", "cairo_tag_end", "(", "self", ".", "_pointer", ",", "_encode_string", "(", "tag_name", ")", ")", "self", ".", "_check_status", "(", ")" ]
Marks the end of the ``tag_name`` structure. Invalid nesting of tags will cause @cr to shutdown with a status of ``CAIRO_STATUS_TAG_ERROR``. See :meth:`tag_begin`. :param tag_name: tag name *New in cairo 1.16.* *New in cairocffi 0.9.*
[ "Marks", "the", "end", "of", "the", "tag_name", "structure", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L2242-L2258
17,602
Kozea/cairocffi
cairocffi/surfaces.py
_make_read_func
def _make_read_func(file_obj): """Return a CFFI callback that reads from a file-like object.""" @ffi.callback("cairo_read_func_t", error=constants.STATUS_READ_ERROR) def read_func(_closure, data, length): string = file_obj.read(length) if len(string) < length: # EOF too early re...
python
def _make_read_func(file_obj): """Return a CFFI callback that reads from a file-like object.""" @ffi.callback("cairo_read_func_t", error=constants.STATUS_READ_ERROR) def read_func(_closure, data, length): string = file_obj.read(length) if len(string) < length: # EOF too early re...
[ "def", "_make_read_func", "(", "file_obj", ")", ":", "@", "ffi", ".", "callback", "(", "\"cairo_read_func_t\"", ",", "error", "=", "constants", ".", "STATUS_READ_ERROR", ")", "def", "read_func", "(", "_closure", ",", "data", ",", "length", ")", ":", "string"...
Return a CFFI callback that reads from a file-like object.
[ "Return", "a", "CFFI", "callback", "that", "reads", "from", "a", "file", "-", "like", "object", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L24-L33
17,603
Kozea/cairocffi
cairocffi/surfaces.py
_make_write_func
def _make_write_func(file_obj): """Return a CFFI callback that writes to a file-like object.""" if file_obj is None: return ffi.NULL @ffi.callback("cairo_write_func_t", error=constants.STATUS_WRITE_ERROR) def write_func(_closure, data, length): file_obj.write(ffi.buffer(data, length)) ...
python
def _make_write_func(file_obj): """Return a CFFI callback that writes to a file-like object.""" if file_obj is None: return ffi.NULL @ffi.callback("cairo_write_func_t", error=constants.STATUS_WRITE_ERROR) def write_func(_closure, data, length): file_obj.write(ffi.buffer(data, length)) ...
[ "def", "_make_write_func", "(", "file_obj", ")", ":", "if", "file_obj", "is", "None", ":", "return", "ffi", ".", "NULL", "@", "ffi", ".", "callback", "(", "\"cairo_write_func_t\"", ",", "error", "=", "constants", ".", "STATUS_WRITE_ERROR", ")", "def", "write...
Return a CFFI callback that writes to a file-like object.
[ "Return", "a", "CFFI", "callback", "that", "writes", "to", "a", "file", "-", "like", "object", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L36-L45
17,604
Kozea/cairocffi
cairocffi/surfaces.py
_encode_filename
def _encode_filename(filename): # pragma: no cover """Return a byte string suitable for a filename. Unicode is encoded using an encoding adapted to what both cairo and the filesystem want. """ # Don't replace unknown characters as '?' is forbidden in Windows filenames errors = 'ignore' if os....
python
def _encode_filename(filename): # pragma: no cover """Return a byte string suitable for a filename. Unicode is encoded using an encoding adapted to what both cairo and the filesystem want. """ # Don't replace unknown characters as '?' is forbidden in Windows filenames errors = 'ignore' if os....
[ "def", "_encode_filename", "(", "filename", ")", ":", "# pragma: no cover", "# Don't replace unknown characters as '?' is forbidden in Windows filenames", "errors", "=", "'ignore'", "if", "os", ".", "name", "==", "'nt'", "else", "'replace'", "if", "not", "isinstance", "("...
Return a byte string suitable for a filename. Unicode is encoded using an encoding adapted to what both cairo and the filesystem want.
[ "Return", "a", "byte", "string", "suitable", "for", "a", "filename", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L48-L70
17,605
Kozea/cairocffi
cairocffi/surfaces.py
Surface.create_similar_image
def create_similar_image(self, content, width, height): """ Create a new image surface that is as compatible as possible for uploading to and the use in conjunction with this surface. However, this surface can still be used like any normal image surface. Initially the surface co...
python
def create_similar_image(self, content, width, height): """ Create a new image surface that is as compatible as possible for uploading to and the use in conjunction with this surface. However, this surface can still be used like any normal image surface. Initially the surface co...
[ "def", "create_similar_image", "(", "self", ",", "content", ",", "width", ",", "height", ")", ":", "return", "Surface", ".", "_from_pointer", "(", "cairo", ".", "cairo_surface_create_similar_image", "(", "self", ".", "_pointer", ",", "content", ",", "width", "...
Create a new image surface that is as compatible as possible for uploading to and the use in conjunction with this surface. However, this surface can still be used like any normal image surface. Initially the surface contents are all 0 (transparent if contents have transparency, black o...
[ "Create", "a", "new", "image", "surface", "that", "is", "as", "compatible", "as", "possible", "for", "uploading", "to", "and", "the", "use", "in", "conjunction", "with", "this", "surface", ".", "However", "this", "surface", "can", "still", "be", "used", "l...
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L209-L232
17,606
Kozea/cairocffi
cairocffi/surfaces.py
Surface.create_for_rectangle
def create_for_rectangle(self, x, y, width, height): """ Create a new surface that is a rectangle within this surface. All operations drawn to this surface are then clipped and translated onto the target surface. Nothing drawn via this sub-surface outside of its bounds is...
python
def create_for_rectangle(self, x, y, width, height): """ Create a new surface that is a rectangle within this surface. All operations drawn to this surface are then clipped and translated onto the target surface. Nothing drawn via this sub-surface outside of its bounds is...
[ "def", "create_for_rectangle", "(", "self", ",", "x", ",", "y", ",", "width", ",", "height", ")", ":", "return", "Surface", ".", "_from_pointer", "(", "cairo", ".", "cairo_surface_create_for_rectangle", "(", "self", ".", "_pointer", ",", "x", ",", "y", ","...
Create a new surface that is a rectangle within this surface. All operations drawn to this surface are then clipped and translated onto the target surface. Nothing drawn via this sub-surface outside of its bounds is drawn onto the target surface, making this a useful method for p...
[ "Create", "a", "new", "surface", "that", "is", "a", "rectangle", "within", "this", "surface", ".", "All", "operations", "drawn", "to", "this", "surface", "are", "then", "clipped", "and", "translated", "onto", "the", "target", "surface", ".", "Nothing", "draw...
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L234-L277
17,607
Kozea/cairocffi
cairocffi/surfaces.py
Surface.set_fallback_resolution
def set_fallback_resolution(self, x_pixels_per_inch, y_pixels_per_inch): """ Set the horizontal and vertical resolution for image fallbacks. When certain operations aren't supported natively by a backend, cairo will fallback by rendering operations to an image and then overlayin...
python
def set_fallback_resolution(self, x_pixels_per_inch, y_pixels_per_inch): """ Set the horizontal and vertical resolution for image fallbacks. When certain operations aren't supported natively by a backend, cairo will fallback by rendering operations to an image and then overlayin...
[ "def", "set_fallback_resolution", "(", "self", ",", "x_pixels_per_inch", ",", "y_pixels_per_inch", ")", ":", "cairo", ".", "cairo_surface_set_fallback_resolution", "(", "self", ".", "_pointer", ",", "x_pixels_per_inch", ",", "y_pixels_per_inch", ")", "self", ".", "_ch...
Set the horizontal and vertical resolution for image fallbacks. When certain operations aren't supported natively by a backend, cairo will fallback by rendering operations to an image and then overlaying that image onto the output. For backends that are natively vector-oriented, ...
[ "Set", "the", "horizontal", "and", "vertical", "resolution", "for", "image", "fallbacks", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L342-L382
17,608
Kozea/cairocffi
cairocffi/surfaces.py
Surface.get_font_options
def get_font_options(self): """Retrieves the default font rendering options for the surface. This allows display surfaces to report the correct subpixel order for rendering on them, print surfaces to disable hinting of metrics and so forth. The result can then be used with :clas...
python
def get_font_options(self): """Retrieves the default font rendering options for the surface. This allows display surfaces to report the correct subpixel order for rendering on them, print surfaces to disable hinting of metrics and so forth. The result can then be used with :clas...
[ "def", "get_font_options", "(", "self", ")", ":", "font_options", "=", "FontOptions", "(", ")", "cairo", ".", "cairo_surface_get_font_options", "(", "self", ".", "_pointer", ",", "font_options", ".", "_pointer", ")", "return", "font_options" ]
Retrieves the default font rendering options for the surface. This allows display surfaces to report the correct subpixel order for rendering on them, print surfaces to disable hinting of metrics and so forth. The result can then be used with :class:`ScaledFont`. :returns: A ne...
[ "Retrieves", "the", "default", "font", "rendering", "options", "for", "the", "surface", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L397-L411
17,609
Kozea/cairocffi
cairocffi/surfaces.py
Surface.set_device_scale
def set_device_scale(self, x_scale, y_scale): """Sets a scale that is multiplied to the device coordinates determined by the CTM when drawing to surface. One common use for this is to render to very high resolution display devices at a scale factor, so that code that assumes 1 pixel wil...
python
def set_device_scale(self, x_scale, y_scale): """Sets a scale that is multiplied to the device coordinates determined by the CTM when drawing to surface. One common use for this is to render to very high resolution display devices at a scale factor, so that code that assumes 1 pixel wil...
[ "def", "set_device_scale", "(", "self", ",", "x_scale", ",", "y_scale", ")", ":", "cairo", ".", "cairo_surface_set_device_scale", "(", "self", ".", "_pointer", ",", "x_scale", ",", "y_scale", ")", "self", ".", "_check_status", "(", ")" ]
Sets a scale that is multiplied to the device coordinates determined by the CTM when drawing to surface. One common use for this is to render to very high resolution display devices at a scale factor, so that code that assumes 1 pixel will be a certain size will still work. Setting a t...
[ "Sets", "a", "scale", "that", "is", "multiplied", "to", "the", "device", "coordinates", "determined", "by", "the", "CTM", "when", "drawing", "to", "surface", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L413-L435
17,610
Kozea/cairocffi
cairocffi/surfaces.py
Surface.get_mime_data
def get_mime_data(self, mime_type): """Return mime data previously attached to surface using the specified mime type. :param mime_type: The MIME type of the image data. :type mime_type: ASCII string :returns: A CFFI buffer object, or :obj:`None` if no dat...
python
def get_mime_data(self, mime_type): """Return mime data previously attached to surface using the specified mime type. :param mime_type: The MIME type of the image data. :type mime_type: ASCII string :returns: A CFFI buffer object, or :obj:`None` if no dat...
[ "def", "get_mime_data", "(", "self", ",", "mime_type", ")", ":", "buffer_address", "=", "ffi", ".", "new", "(", "'unsigned char **'", ")", "buffer_length", "=", "ffi", ".", "new", "(", "'unsigned long *'", ")", "mime_type", "=", "ffi", ".", "new", "(", "'c...
Return mime data previously attached to surface using the specified mime type. :param mime_type: The MIME type of the image data. :type mime_type: ASCII string :returns: A CFFI buffer object, or :obj:`None` if no data has been attached with the given mime type. ...
[ "Return", "mime", "data", "previously", "attached", "to", "surface", "using", "the", "specified", "mime", "type", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L504-L523
17,611
Kozea/cairocffi
cairocffi/surfaces.py
Surface.write_to_png
def write_to_png(self, target=None): """Writes the contents of surface as a PNG image. :param target: A filename, a binary mode file-like object with a :meth:`~file.write` method, or :obj:`None`. :returns: If :obj:`target` is :obj:`None`, ...
python
def write_to_png(self, target=None): """Writes the contents of surface as a PNG image. :param target: A filename, a binary mode file-like object with a :meth:`~file.write` method, or :obj:`None`. :returns: If :obj:`target` is :obj:`None`, ...
[ "def", "write_to_png", "(", "self", ",", "target", "=", "None", ")", ":", "return_bytes", "=", "target", "is", "None", "if", "return_bytes", ":", "target", "=", "io", ".", "BytesIO", "(", ")", "if", "hasattr", "(", "target", ",", "'write'", ")", ":", ...
Writes the contents of surface as a PNG image. :param target: A filename, a binary mode file-like object with a :meth:`~file.write` method, or :obj:`None`. :returns: If :obj:`target` is :obj:`None`, return the PNG contents as a byte string.
[ "Writes", "the", "contents", "of", "surface", "as", "a", "PNG", "image", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L630-L653
17,612
Kozea/cairocffi
cairocffi/surfaces.py
ImageSurface.create_from_png
def create_from_png(cls, source): """Decode a PNG file into a new image surface. :param source: A filename or a binary mode file-like object with a :meth:`~file.read` method. If you already have a byte string in memory, use :class:`io.BytesIO`. :r...
python
def create_from_png(cls, source): """Decode a PNG file into a new image surface. :param source: A filename or a binary mode file-like object with a :meth:`~file.read` method. If you already have a byte string in memory, use :class:`io.BytesIO`. :r...
[ "def", "create_from_png", "(", "cls", ",", "source", ")", ":", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "read_func", "=", "_make_read_func", "(", "source", ")", "pointer", "=", "cairo", ".", "cairo_image_surface_create_from_png_stream", "(", "r...
Decode a PNG file into a new image surface. :param source: A filename or a binary mode file-like object with a :meth:`~file.read` method. If you already have a byte string in memory, use :class:`io.BytesIO`. :returns: A new :class:`ImageSurface` instance.
[ "Decode", "a", "PNG", "file", "into", "a", "new", "image", "surface", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L742-L762
17,613
Kozea/cairocffi
cairocffi/surfaces.py
PDFSurface.add_outline
def add_outline(self, parent_id, utf8, link_attribs, flags=None): """Add an item to the document outline hierarchy. The outline has the ``utf8`` name and links to the location specified by ``link_attribs``. Link attributes have the same keys and values as the Link Tag, excluding the ``r...
python
def add_outline(self, parent_id, utf8, link_attribs, flags=None): """Add an item to the document outline hierarchy. The outline has the ``utf8`` name and links to the location specified by ``link_attribs``. Link attributes have the same keys and values as the Link Tag, excluding the ``r...
[ "def", "add_outline", "(", "self", ",", "parent_id", ",", "utf8", ",", "link_attribs", ",", "flags", "=", "None", ")", ":", "if", "flags", "is", "None", ":", "flags", "=", "0", "value", "=", "cairo", ".", "cairo_pdf_surface_add_outline", "(", "self", "."...
Add an item to the document outline hierarchy. The outline has the ``utf8`` name and links to the location specified by ``link_attribs``. Link attributes have the same keys and values as the Link Tag, excluding the ``rect`` attribute. The item will be a child of the item with id ``paren...
[ "Add", "an", "item", "to", "the", "document", "outline", "hierarchy", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L873-L903
17,614
Kozea/cairocffi
cairocffi/surfaces.py
PDFSurface.set_metadata
def set_metadata(self, metadata, utf8): """Sets document metadata. The ``PDF_METADATA_CREATE_DATE`` and ``PDF_METADATA_MOD_DATE`` values must be in ISO-8601 format: YYYY-MM-DDThh:mm:ss. An optional timezone of the form "[+/-]hh:mm" or "Z" for UTC time can be appended. All other ...
python
def set_metadata(self, metadata, utf8): """Sets document metadata. The ``PDF_METADATA_CREATE_DATE`` and ``PDF_METADATA_MOD_DATE`` values must be in ISO-8601 format: YYYY-MM-DDThh:mm:ss. An optional timezone of the form "[+/-]hh:mm" or "Z" for UTC time can be appended. All other ...
[ "def", "set_metadata", "(", "self", ",", "metadata", ",", "utf8", ")", ":", "cairo", ".", "cairo_pdf_surface_set_metadata", "(", "self", ".", "_pointer", ",", "metadata", ",", "_encode_string", "(", "utf8", ")", ")", "self", ".", "_check_status", "(", ")" ]
Sets document metadata. The ``PDF_METADATA_CREATE_DATE`` and ``PDF_METADATA_MOD_DATE`` values must be in ISO-8601 format: YYYY-MM-DDThh:mm:ss. An optional timezone of the form "[+/-]hh:mm" or "Z" for UTC time can be appended. All other metadata values can be any UTF-8 string. :...
[ "Sets", "document", "metadata", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L905-L923
17,615
Kozea/cairocffi
cairocffi/surfaces.py
PDFSurface.set_thumbnail_size
def set_thumbnail_size(self, width, height): """Set thumbnail image size for the current and all subsequent pages. Setting a width or height of 0 disables thumbnails for the current and subsequent pages. :param width: thumbnail width. :param height: thumbnail height. *...
python
def set_thumbnail_size(self, width, height): """Set thumbnail image size for the current and all subsequent pages. Setting a width or height of 0 disables thumbnails for the current and subsequent pages. :param width: thumbnail width. :param height: thumbnail height. *...
[ "def", "set_thumbnail_size", "(", "self", ",", "width", ",", "height", ")", ":", "cairo", ".", "cairo_pdf_surface_set_thumbnail_size", "(", "self", ".", "_pointer", ",", "width", ",", "height", ")" ]
Set thumbnail image size for the current and all subsequent pages. Setting a width or height of 0 disables thumbnails for the current and subsequent pages. :param width: thumbnail width. :param height: thumbnail height. *New in cairo 1.16.* *New in cairocffi 0.9.*
[ "Set", "thumbnail", "image", "size", "for", "the", "current", "and", "all", "subsequent", "pages", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L938-L953
17,616
Kozea/cairocffi
cairocffi/surfaces.py
PSSurface.dsc_comment
def dsc_comment(self, comment): """ Emit a comment into the PostScript output for the given surface. The comment is expected to conform to the PostScript Language Document Structuring Conventions (DSC). Please see that manual for details on the available comments and their meani...
python
def dsc_comment(self, comment): """ Emit a comment into the PostScript output for the given surface. The comment is expected to conform to the PostScript Language Document Structuring Conventions (DSC). Please see that manual for details on the available comments and their meani...
[ "def", "dsc_comment", "(", "self", ",", "comment", ")", ":", "cairo", ".", "cairo_ps_surface_dsc_comment", "(", "self", ".", "_pointer", ",", "_encode_string", "(", "comment", ")", ")", "self", ".", "_check_status", "(", ")" ]
Emit a comment into the PostScript output for the given surface. The comment is expected to conform to the PostScript Language Document Structuring Conventions (DSC). Please see that manual for details on the available comments and their meanings. In particular, the ``%%IncludeF...
[ "Emit", "a", "comment", "into", "the", "PostScript", "output", "for", "the", "given", "surface", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L1047-L1123
17,617
Kozea/cairocffi
cairocffi/surfaces.py
SVGSurface.set_document_unit
def set_document_unit(self, unit): """Use specified unit for width and height of generated SVG file. See ``SVG_UNIT_*`` enumerated values for a list of available unit values that can be used here. This function can be called at any time before generating the SVG file. However ...
python
def set_document_unit(self, unit): """Use specified unit for width and height of generated SVG file. See ``SVG_UNIT_*`` enumerated values for a list of available unit values that can be used here. This function can be called at any time before generating the SVG file. However ...
[ "def", "set_document_unit", "(", "self", ",", "unit", ")", ":", "cairo", ".", "cairo_svg_surface_set_document_unit", "(", "self", ".", "_pointer", ",", "unit", ")", "self", ".", "_check_status", "(", ")" ]
Use specified unit for width and height of generated SVG file. See ``SVG_UNIT_*`` enumerated values for a list of available unit values that can be used here. This function can be called at any time before generating the SVG file. However to minimize the risk of ambiguities it's recom...
[ "Use", "specified", "unit", "for", "width", "and", "height", "of", "generated", "SVG", "file", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L1309-L1336
17,618
Kozea/cairocffi
cairocffi/surfaces.py
SVGSurface.get_document_unit
def get_document_unit(self): """Get the unit of the SVG surface. If the surface passed as an argument is not a SVG surface, the function sets the error status to ``STATUS_SURFACE_TYPE_MISMATCH`` and returns :ref:`SVG_UNIT_USER`. :return: The SVG unit of the SVG surface. ...
python
def get_document_unit(self): """Get the unit of the SVG surface. If the surface passed as an argument is not a SVG surface, the function sets the error status to ``STATUS_SURFACE_TYPE_MISMATCH`` and returns :ref:`SVG_UNIT_USER`. :return: The SVG unit of the SVG surface. ...
[ "def", "get_document_unit", "(", "self", ")", ":", "unit", "=", "cairo", ".", "cairo_svg_surface_get_document_unit", "(", "self", ".", "_pointer", ")", "self", ".", "_check_status", "(", ")", "return", "unit" ]
Get the unit of the SVG surface. If the surface passed as an argument is not a SVG surface, the function sets the error status to ``STATUS_SURFACE_TYPE_MISMATCH`` and returns :ref:`SVG_UNIT_USER`. :return: The SVG unit of the SVG surface. *New in cairo 1.16.* *New in ...
[ "Get", "the", "unit", "of", "the", "SVG", "surface", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L1338-L1354
17,619
Kozea/cairocffi
cairocffi/surfaces.py
RecordingSurface.get_extents
def get_extents(self): """Return the extents of the recording-surface. :returns: A ``(x, y, width, height)`` tuple of floats, or :obj:`None` if the surface is unbounded. *New in cairo 1.12* """ extents = ffi.new('cairo_rectangle_t *') if cairo.c...
python
def get_extents(self): """Return the extents of the recording-surface. :returns: A ``(x, y, width, height)`` tuple of floats, or :obj:`None` if the surface is unbounded. *New in cairo 1.12* """ extents = ffi.new('cairo_rectangle_t *') if cairo.c...
[ "def", "get_extents", "(", "self", ")", ":", "extents", "=", "ffi", ".", "new", "(", "'cairo_rectangle_t *'", ")", "if", "cairo", ".", "cairo_recording_surface_get_extents", "(", "self", ".", "_pointer", ",", "extents", ")", ":", "return", "(", "extents", "....
Return the extents of the recording-surface. :returns: A ``(x, y, width, height)`` tuple of floats, or :obj:`None` if the surface is unbounded. *New in cairo 1.12*
[ "Return", "the", "extents", "of", "the", "recording", "-", "surface", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/surfaces.py#L1430-L1442
17,620
Kozea/cairocffi
cairocffi/patterns.py
Gradient.add_color_stop_rgba
def add_color_stop_rgba(self, offset, red, green, blue, alpha=1): """Adds a translucent color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a rad...
python
def add_color_stop_rgba(self, offset, red, green, blue, alpha=1): """Adds a translucent color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a rad...
[ "def", "add_color_stop_rgba", "(", "self", ",", "offset", ",", "red", ",", "green", ",", "blue", ",", "alpha", "=", "1", ")", ":", "cairo", ".", "cairo_pattern_add_color_stop_rgba", "(", "self", ".", "_pointer", ",", "offset", ",", "red", ",", "green", "...
Adds a translucent color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a radial gradient's control vector is from any point on the start circle ...
[ "Adds", "a", "translucent", "color", "stop", "to", "a", "gradient", "pattern", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/patterns.py#L219-L255
17,621
Kozea/cairocffi
cairocffi/fonts.py
_encode_string
def _encode_string(string): """Return a byte string, encoding Unicode with UTF-8.""" if not isinstance(string, bytes): string = string.encode('utf8') return ffi.new('char[]', string)
python
def _encode_string(string): """Return a byte string, encoding Unicode with UTF-8.""" if not isinstance(string, bytes): string = string.encode('utf8') return ffi.new('char[]', string)
[ "def", "_encode_string", "(", "string", ")", ":", "if", "not", "isinstance", "(", "string", ",", "bytes", ")", ":", "string", "=", "string", ".", "encode", "(", "'utf8'", ")", "return", "ffi", ".", "new", "(", "'char[]'", ",", "string", ")" ]
Return a byte string, encoding Unicode with UTF-8.
[ "Return", "a", "byte", "string", "encoding", "Unicode", "with", "UTF", "-", "8", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/fonts.py#L16-L20
17,622
Kozea/cairocffi
cairocffi/fonts.py
ScaledFont.text_to_glyphs
def text_to_glyphs(self, x, y, text, with_clusters): """Converts a string of text to a list of glyphs, optionally with cluster mapping, that can be used to render later using this scaled font. The output values can be readily passed to :meth:`Context.show_text_glyphs`, :meth:`Co...
python
def text_to_glyphs(self, x, y, text, with_clusters): """Converts a string of text to a list of glyphs, optionally with cluster mapping, that can be used to render later using this scaled font. The output values can be readily passed to :meth:`Context.show_text_glyphs`, :meth:`Co...
[ "def", "text_to_glyphs", "(", "self", ",", "x", ",", "y", ",", "text", ",", "with_clusters", ")", ":", "glyphs", "=", "ffi", ".", "new", "(", "'cairo_glyph_t **'", ",", "ffi", ".", "NULL", ")", "num_glyphs", "=", "ffi", ".", "new", "(", "'int *'", ")...
Converts a string of text to a list of glyphs, optionally with cluster mapping, that can be used to render later using this scaled font. The output values can be readily passed to :meth:`Context.show_text_glyphs`, :meth:`Context.show_glyphs` or related methods, assuming ...
[ "Converts", "a", "string", "of", "text", "to", "a", "list", "of", "glyphs", "optionally", "with", "cluster", "mapping", "that", "can", "be", "used", "to", "render", "later", "using", "this", "scaled", "font", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/fonts.py#L301-L366
17,623
Kozea/cairocffi
cairocffi/fonts.py
FontOptions.set_variations
def set_variations(self, variations): """Sets the OpenType font variations for the font options object. Font variations are specified as a string with a format that is similar to the CSS font-variation-settings. The string contains a comma-separated list of axis assignments, which each ...
python
def set_variations(self, variations): """Sets the OpenType font variations for the font options object. Font variations are specified as a string with a format that is similar to the CSS font-variation-settings. The string contains a comma-separated list of axis assignments, which each ...
[ "def", "set_variations", "(", "self", ",", "variations", ")", ":", "if", "variations", "is", "None", ":", "variations", "=", "ffi", ".", "NULL", "else", ":", "variations", "=", "_encode_string", "(", "variations", ")", "cairo", ".", "cairo_font_options_set_var...
Sets the OpenType font variations for the font options object. Font variations are specified as a string with a format that is similar to the CSS font-variation-settings. The string contains a comma-separated list of axis assignments, which each assignment consists of a 4-character axis...
[ "Sets", "the", "OpenType", "font", "variations", "for", "the", "font", "options", "object", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/fonts.py#L494-L515
17,624
Kozea/cairocffi
cairocffi/fonts.py
FontOptions.get_variations
def get_variations(self): """Gets the OpenType font variations for the font options object. See :meth:`set_variations` for details about the string format. :return: the font variations for the font options object. The returned string belongs to the ``options`` and must not be m...
python
def get_variations(self): """Gets the OpenType font variations for the font options object. See :meth:`set_variations` for details about the string format. :return: the font variations for the font options object. The returned string belongs to the ``options`` and must not be m...
[ "def", "get_variations", "(", "self", ")", ":", "variations", "=", "cairo", ".", "cairo_font_options_get_variations", "(", "self", ".", "_pointer", ")", "if", "variations", "!=", "ffi", ".", "NULL", ":", "return", "ffi", ".", "string", "(", "variations", ")"...
Gets the OpenType font variations for the font options object. See :meth:`set_variations` for details about the string format. :return: the font variations for the font options object. The returned string belongs to the ``options`` and must not be modified. It is valid until ei...
[ "Gets", "the", "OpenType", "font", "variations", "for", "the", "font", "options", "object", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/fonts.py#L517-L535
17,625
Kozea/cairocffi
cairocffi/pixbuf.py
decode_to_pixbuf
def decode_to_pixbuf(image_data, width=None, height=None): """Decode an image from memory with GDK-PixBuf. The file format is detected automatically. :param image_data: A byte string :param width: Integer width in pixels or None :param height: Integer height in pixels or None :returns: ...
python
def decode_to_pixbuf(image_data, width=None, height=None): """Decode an image from memory with GDK-PixBuf. The file format is detected automatically. :param image_data: A byte string :param width: Integer width in pixels or None :param height: Integer height in pixels or None :returns: ...
[ "def", "decode_to_pixbuf", "(", "image_data", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "loader", "=", "ffi", ".", "gc", "(", "gdk_pixbuf", ".", "gdk_pixbuf_loader_new", "(", ")", ",", "gobject", ".", "g_object_unref", ")", "error", ...
Decode an image from memory with GDK-PixBuf. The file format is detected automatically. :param image_data: A byte string :param width: Integer width in pixels or None :param height: Integer height in pixels or None :returns: A tuple of a new :class:`PixBuf` object and the name of th...
[ "Decode", "an", "image", "from", "memory", "with", "GDK", "-", "PixBuf", ".", "The", "file", "format", "is", "detected", "automatically", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/pixbuf.py#L69-L102
17,626
Kozea/cairocffi
cairocffi/pixbuf.py
decode_to_image_surface
def decode_to_image_surface(image_data, width=None, height=None): """Decode an image from memory into a cairo surface. The file format is detected automatically. :param image_data: A byte string :param width: Integer width in pixels or None :param height: Integer height in pixels or None :retur...
python
def decode_to_image_surface(image_data, width=None, height=None): """Decode an image from memory into a cairo surface. The file format is detected automatically. :param image_data: A byte string :param width: Integer width in pixels or None :param height: Integer height in pixels or None :retur...
[ "def", "decode_to_image_surface", "(", "image_data", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "pixbuf", ",", "format_name", "=", "decode_to_pixbuf", "(", "image_data", ",", "width", ",", "height", ")", "surface", "=", "(", "pixbuf_to_...
Decode an image from memory into a cairo surface. The file format is detected automatically. :param image_data: A byte string :param width: Integer width in pixels or None :param height: Integer height in pixels or None :returns: A tuple of a new :class:`~cairocffi.ImageSurface` object ...
[ "Decode", "an", "image", "from", "memory", "into", "a", "cairo", "surface", ".", "The", "file", "format", "is", "detected", "automatically", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/pixbuf.py#L105-L125
17,627
Kozea/cairocffi
cairocffi/pixbuf.py
pixbuf_to_cairo_gdk
def pixbuf_to_cairo_gdk(pixbuf): """Convert from PixBuf to ImageSurface, using GDK. This method is fastest but GDK is not always available. """ dummy_context = Context(ImageSurface(constants.FORMAT_ARGB32, 1, 1)) gdk.gdk_cairo_set_source_pixbuf( dummy_context._pointer, pixbuf._pointer, 0, ...
python
def pixbuf_to_cairo_gdk(pixbuf): """Convert from PixBuf to ImageSurface, using GDK. This method is fastest but GDK is not always available. """ dummy_context = Context(ImageSurface(constants.FORMAT_ARGB32, 1, 1)) gdk.gdk_cairo_set_source_pixbuf( dummy_context._pointer, pixbuf._pointer, 0, ...
[ "def", "pixbuf_to_cairo_gdk", "(", "pixbuf", ")", ":", "dummy_context", "=", "Context", "(", "ImageSurface", "(", "constants", ".", "FORMAT_ARGB32", ",", "1", ",", "1", ")", ")", "gdk", ".", "gdk_cairo_set_source_pixbuf", "(", "dummy_context", ".", "_pointer", ...
Convert from PixBuf to ImageSurface, using GDK. This method is fastest but GDK is not always available.
[ "Convert", "from", "PixBuf", "to", "ImageSurface", "using", "GDK", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/pixbuf.py#L128-L137
17,628
Kozea/cairocffi
cairocffi/pixbuf.py
pixbuf_to_cairo_slices
def pixbuf_to_cairo_slices(pixbuf): """Convert from PixBuf to ImageSurface, using slice-based byte swapping. This method is 2~5x slower than GDK but does not support an alpha channel. (cairo uses pre-multiplied alpha, but not Pixbuf.) """ assert pixbuf.get_colorspace() == gdk_pixbuf.GDK_COLORSPACE...
python
def pixbuf_to_cairo_slices(pixbuf): """Convert from PixBuf to ImageSurface, using slice-based byte swapping. This method is 2~5x slower than GDK but does not support an alpha channel. (cairo uses pre-multiplied alpha, but not Pixbuf.) """ assert pixbuf.get_colorspace() == gdk_pixbuf.GDK_COLORSPACE...
[ "def", "pixbuf_to_cairo_slices", "(", "pixbuf", ")", ":", "assert", "pixbuf", ".", "get_colorspace", "(", ")", "==", "gdk_pixbuf", ".", "GDK_COLORSPACE_RGB", "assert", "pixbuf", ".", "get_n_channels", "(", ")", "==", "3", "assert", "pixbuf", ".", "get_bits_per_s...
Convert from PixBuf to ImageSurface, using slice-based byte swapping. This method is 2~5x slower than GDK but does not support an alpha channel. (cairo uses pre-multiplied alpha, but not Pixbuf.)
[ "Convert", "from", "PixBuf", "to", "ImageSurface", "using", "slice", "-", "based", "byte", "swapping", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/pixbuf.py#L140-L187
17,629
Kozea/cairocffi
cairocffi/pixbuf.py
pixbuf_to_cairo_png
def pixbuf_to_cairo_png(pixbuf): """Convert from PixBuf to ImageSurface, by going through the PNG format. This method is 10~30x slower than GDK but always works. """ buffer_pointer = ffi.new('gchar **') buffer_size = ffi.new('gsize *') error = ffi.new('GError **') handle_g_error(error, pix...
python
def pixbuf_to_cairo_png(pixbuf): """Convert from PixBuf to ImageSurface, by going through the PNG format. This method is 10~30x slower than GDK but always works. """ buffer_pointer = ffi.new('gchar **') buffer_size = ffi.new('gsize *') error = ffi.new('GError **') handle_g_error(error, pix...
[ "def", "pixbuf_to_cairo_png", "(", "pixbuf", ")", ":", "buffer_pointer", "=", "ffi", ".", "new", "(", "'gchar **'", ")", "buffer_size", "=", "ffi", ".", "new", "(", "'gsize *'", ")", "error", "=", "ffi", ".", "new", "(", "'GError **'", ")", "handle_g_error...
Convert from PixBuf to ImageSurface, by going through the PNG format. This method is 10~30x slower than GDK but always works.
[ "Convert", "from", "PixBuf", "to", "ImageSurface", "by", "going", "through", "the", "PNG", "format", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/pixbuf.py#L190-L204
17,630
coderholic/pyradio
pyradio/player.py
probePlayer
def probePlayer(requested_player=''): """ Probes the multimedia players which are available on the host system.""" ret_player = None if logger.isEnabledFor(logging.INFO): logger.info("Probing available multimedia players...") implementedPlayers = Player.__subclasses__() if logger.isEnabl...
python
def probePlayer(requested_player=''): """ Probes the multimedia players which are available on the host system.""" ret_player = None if logger.isEnabledFor(logging.INFO): logger.info("Probing available multimedia players...") implementedPlayers = Player.__subclasses__() if logger.isEnabl...
[ "def", "probePlayer", "(", "requested_player", "=", "''", ")", ":", "ret_player", "=", "None", "if", "logger", ".", "isEnabledFor", "(", "logging", ".", "INFO", ")", ":", "logger", ".", "info", "(", "\"Probing available multimedia players...\"", ")", "implemente...
Probes the multimedia players which are available on the host system.
[ "Probes", "the", "multimedia", "players", "which", "are", "available", "on", "the", "host", "system", "." ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/player.py#L763-L793
17,631
coderholic/pyradio
pyradio/player.py
Player.play
def play(self, name, streamUrl, encoding = ''): """ use a multimedia player to play a stream """ self.close() self.name = name self.oldUserInput = {'Input': '', 'Volume': '', 'Title': ''} self.muted = False self.show_volume = True self.title_prefix = '' se...
python
def play(self, name, streamUrl, encoding = ''): """ use a multimedia player to play a stream """ self.close() self.name = name self.oldUserInput = {'Input': '', 'Volume': '', 'Title': ''} self.muted = False self.show_volume = True self.title_prefix = '' se...
[ "def", "play", "(", "self", ",", "name", ",", "streamUrl", ",", "encoding", "=", "''", ")", ":", "self", ".", "close", "(", ")", "self", ".", "name", "=", "name", "self", ".", "oldUserInput", "=", "{", "'Input'", ":", "''", ",", "'Volume'", ":", ...
use a multimedia player to play a stream
[ "use", "a", "multimedia", "player", "to", "play", "a", "stream" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/player.py#L285-L319
17,632
coderholic/pyradio
pyradio/player.py
Player._sendCommand
def _sendCommand(self, command): """ send keystroke command to player """ if(self.process is not None): try: if logger.isEnabledFor(logging.DEBUG): logger.debug("Command: {}".format(command).strip()) self.process.stdin.write(command.encode...
python
def _sendCommand(self, command): """ send keystroke command to player """ if(self.process is not None): try: if logger.isEnabledFor(logging.DEBUG): logger.debug("Command: {}".format(command).strip()) self.process.stdin.write(command.encode...
[ "def", "_sendCommand", "(", "self", ",", "command", ")", ":", "if", "(", "self", ".", "process", "is", "not", "None", ")", ":", "try", ":", "if", "logger", ".", "isEnabledFor", "(", "logging", ".", "DEBUG", ")", ":", "logger", ".", "debug", "(", "\...
send keystroke command to player
[ "send", "keystroke", "command", "to", "player" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/player.py#L321-L333
17,633
coderholic/pyradio
pyradio/player.py
MpvPlayer._format_title_string
def _format_title_string(self, title_string): """ format mpv's title """ return self._title_string_format_text_tag(title_string.replace(self.icy_tokkens[0], self.icy_title_prefix))
python
def _format_title_string(self, title_string): """ format mpv's title """ return self._title_string_format_text_tag(title_string.replace(self.icy_tokkens[0], self.icy_title_prefix))
[ "def", "_format_title_string", "(", "self", ",", "title_string", ")", ":", "return", "self", ".", "_title_string_format_text_tag", "(", "title_string", ".", "replace", "(", "self", ".", "icy_tokkens", "[", "0", "]", ",", "self", ".", "icy_title_prefix", ")", "...
format mpv's title
[ "format", "mpv", "s", "title" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/player.py#L529-L531
17,634
coderholic/pyradio
pyradio/player.py
MpPlayer._format_title_string
def _format_title_string(self, title_string): """ format mplayer's title """ if "StreamTitle='" in title_string: tmp = title_string[title_string.find("StreamTitle='"):].replace("StreamTitle='", self.icy_title_prefix) ret_string = tmp[:tmp.find("';")] else: ret...
python
def _format_title_string(self, title_string): """ format mplayer's title """ if "StreamTitle='" in title_string: tmp = title_string[title_string.find("StreamTitle='"):].replace("StreamTitle='", self.icy_title_prefix) ret_string = tmp[:tmp.find("';")] else: ret...
[ "def", "_format_title_string", "(", "self", ",", "title_string", ")", ":", "if", "\"StreamTitle='\"", "in", "title_string", ":", "tmp", "=", "title_string", "[", "title_string", ".", "find", "(", "\"StreamTitle='\"", ")", ":", "]", ".", "replace", "(", "\"Stre...
format mplayer's title
[ "format", "mplayer", "s", "title" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/player.py#L625-L638
17,635
coderholic/pyradio
pyradio/player.py
MpPlayer._format_volume_string
def _format_volume_string(self, volume_string): """ format mplayer's volume """ return '[' + volume_string[volume_string.find(self.volume_string):].replace(' %','%').replace('ume', '')+'] '
python
def _format_volume_string(self, volume_string): """ format mplayer's volume """ return '[' + volume_string[volume_string.find(self.volume_string):].replace(' %','%').replace('ume', '')+'] '
[ "def", "_format_volume_string", "(", "self", ",", "volume_string", ")", ":", "return", "'['", "+", "volume_string", "[", "volume_string", ".", "find", "(", "self", ".", "volume_string", ")", ":", "]", ".", "replace", "(", "' %'", ",", "'%'", ")", ".", "r...
format mplayer's volume
[ "format", "mplayer", "s", "volume" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/player.py#L640-L642
17,636
coderholic/pyradio
pyradio/player.py
VlcPlayer._format_volume_string
def _format_volume_string(self, volume_string): """ format vlc's volume """ self.actual_volume = int(volume_string.split(self.volume_string)[1].split(',')[0].split()[0]) return '[Vol: {}%] '.format(int(100 * self.actual_volume / self.max_volume))
python
def _format_volume_string(self, volume_string): """ format vlc's volume """ self.actual_volume = int(volume_string.split(self.volume_string)[1].split(',')[0].split()[0]) return '[Vol: {}%] '.format(int(100 * self.actual_volume / self.max_volume))
[ "def", "_format_volume_string", "(", "self", ",", "volume_string", ")", ":", "self", ".", "actual_volume", "=", "int", "(", "volume_string", ".", "split", "(", "self", ".", "volume_string", ")", "[", "1", "]", ".", "split", "(", "','", ")", "[", "0", "...
format vlc's volume
[ "format", "vlc", "s", "volume" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/player.py#L706-L709
17,637
coderholic/pyradio
pyradio/player.py
VlcPlayer._format_title_string
def _format_title_string(self, title_string): """ format vlc's title """ sp = title_string.split(self.icy_tokkens[0]) if sp[0] == title_string: ret_string = title_string else: ret_string = self.icy_title_prefix + sp[1] return self._title_string_format_text...
python
def _format_title_string(self, title_string): """ format vlc's title """ sp = title_string.split(self.icy_tokkens[0]) if sp[0] == title_string: ret_string = title_string else: ret_string = self.icy_title_prefix + sp[1] return self._title_string_format_text...
[ "def", "_format_title_string", "(", "self", ",", "title_string", ")", ":", "sp", "=", "title_string", ".", "split", "(", "self", ".", "icy_tokkens", "[", "0", "]", ")", "if", "sp", "[", "0", "]", "==", "title_string", ":", "ret_string", "=", "title_strin...
format vlc's title
[ "format", "vlc", "s", "title" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/player.py#L711-L718
17,638
coderholic/pyradio
pyradio/player.py
VlcPlayer._is_accepted_input
def _is_accepted_input(self, input_string): """ vlc input filtering """ ret = False accept_filter = (self.volume_string, "http stream debug: ") reject_filter = () for n in accept_filter: if n in input_string: ret = True break if...
python
def _is_accepted_input(self, input_string): """ vlc input filtering """ ret = False accept_filter = (self.volume_string, "http stream debug: ") reject_filter = () for n in accept_filter: if n in input_string: ret = True break if...
[ "def", "_is_accepted_input", "(", "self", ",", "input_string", ")", ":", "ret", "=", "False", "accept_filter", "=", "(", "self", ".", "volume_string", ",", "\"http stream debug: \"", ")", "reject_filter", "=", "(", ")", "for", "n", "in", "accept_filter", ":", ...
vlc input filtering
[ "vlc", "input", "filtering" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/player.py#L720-L734
17,639
coderholic/pyradio
pyradio/player.py
VlcPlayer._no_mute_on_stop_playback
def _no_mute_on_stop_playback(self): """ make sure vlc does not stop muted """ if self.ctrl_c_pressed: return if self.isPlaying(): if self.actual_volume == -1: self._get_volume() while self.actual_volume == -1: pass ...
python
def _no_mute_on_stop_playback(self): """ make sure vlc does not stop muted """ if self.ctrl_c_pressed: return if self.isPlaying(): if self.actual_volume == -1: self._get_volume() while self.actual_volume == -1: pass ...
[ "def", "_no_mute_on_stop_playback", "(", "self", ")", ":", "if", "self", ".", "ctrl_c_pressed", ":", "return", "if", "self", ".", "isPlaying", "(", ")", ":", "if", "self", ".", "actual_volume", "==", "-", "1", ":", "self", ".", "_get_volume", "(", ")", ...
make sure vlc does not stop muted
[ "make", "sure", "vlc", "does", "not", "stop", "muted" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/player.py#L741-L761
17,640
coderholic/pyradio
pyradio/config.py
PyRadioStations._check_stations_csv
def _check_stations_csv(self, usr, root): ''' Reclocate a stations.csv copy in user home for easy manage. E.g. not need sudo when you add new station, etc ''' if path.exists(path.join(usr, 'stations.csv')): return else: copyfile(root, path.join(usr, 'stations...
python
def _check_stations_csv(self, usr, root): ''' Reclocate a stations.csv copy in user home for easy manage. E.g. not need sudo when you add new station, etc ''' if path.exists(path.join(usr, 'stations.csv')): return else: copyfile(root, path.join(usr, 'stations...
[ "def", "_check_stations_csv", "(", "self", ",", "usr", ",", "root", ")", ":", "if", "path", ".", "exists", "(", "path", ".", "join", "(", "usr", ",", "'stations.csv'", ")", ")", ":", "return", "else", ":", "copyfile", "(", "root", ",", "path", ".", ...
Reclocate a stations.csv copy in user home for easy manage. E.g. not need sudo when you add new station, etc
[ "Reclocate", "a", "stations", ".", "csv", "copy", "in", "user", "home", "for", "easy", "manage", ".", "E", ".", "g", ".", "not", "need", "sudo", "when", "you", "add", "new", "station", "etc" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L89-L96
17,641
coderholic/pyradio
pyradio/config.py
PyRadioStations._is_playlist_in_config_dir
def _is_playlist_in_config_dir(self): """ Check if a csv file is in the config dir """ if path.dirname(self.stations_file) == self.stations_dir: self.foreign_file = False self.foreign_filename_only_no_extension = '' else: self.foreign_file = True s...
python
def _is_playlist_in_config_dir(self): """ Check if a csv file is in the config dir """ if path.dirname(self.stations_file) == self.stations_dir: self.foreign_file = False self.foreign_filename_only_no_extension = '' else: self.foreign_file = True s...
[ "def", "_is_playlist_in_config_dir", "(", "self", ")", ":", "if", "path", ".", "dirname", "(", "self", ".", "stations_file", ")", "==", "self", ".", "stations_dir", ":", "self", ".", "foreign_file", "=", "False", "self", ".", "foreign_filename_only_no_extension"...
Check if a csv file is in the config dir
[ "Check", "if", "a", "csv", "file", "is", "in", "the", "config", "dir" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L134-L142
17,642
coderholic/pyradio
pyradio/config.py
PyRadioStations._playlist_format_changed
def _playlist_format_changed(self): """ Check if we have new or old format and report if format has changed Format type can change by editing encoding, deleting a non-utf-8 station etc. """ new_format = False for n in self.stations: if n[2...
python
def _playlist_format_changed(self): """ Check if we have new or old format and report if format has changed Format type can change by editing encoding, deleting a non-utf-8 station etc. """ new_format = False for n in self.stations: if n[2...
[ "def", "_playlist_format_changed", "(", "self", ")", ":", "new_format", "=", "False", "for", "n", "in", "self", ".", "stations", ":", "if", "n", "[", "2", "]", "!=", "''", ":", "new_format", "=", "True", "break", "if", "self", ".", "new_format", "==", ...
Check if we have new or old format and report if format has changed Format type can change by editing encoding, deleting a non-utf-8 station etc.
[ "Check", "if", "we", "have", "new", "or", "old", "format", "and", "report", "if", "format", "has", "changed" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L241-L256
17,643
coderholic/pyradio
pyradio/config.py
PyRadioStations.save_playlist_file
def save_playlist_file(self, stationFile=''): """ Save a playlist Create a txt file and write stations in it. Then rename it to final target return 0: All ok -1: Error writing file -2: Error renaming file """ if self._playlist_format_...
python
def save_playlist_file(self, stationFile=''): """ Save a playlist Create a txt file and write stations in it. Then rename it to final target return 0: All ok -1: Error writing file -2: Error renaming file """ if self._playlist_format_...
[ "def", "save_playlist_file", "(", "self", ",", "stationFile", "=", "''", ")", ":", "if", "self", ".", "_playlist_format_changed", "(", ")", ":", "self", ".", "dirty_playlist", "=", "True", "self", ".", "new_format", "=", "not", "self", ".", "new_format", "...
Save a playlist Create a txt file and write stations in it. Then rename it to final target return 0: All ok -1: Error writing file -2: Error renaming file
[ "Save", "a", "playlist", "Create", "a", "txt", "file", "and", "write", "stations", "in", "it", ".", "Then", "rename", "it", "to", "final", "target" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L258-L306
17,644
coderholic/pyradio
pyradio/config.py
PyRadioStations._bytes_to_human
def _bytes_to_human(self, B): ''' Return the given bytes as a human friendly KB, MB, GB, or TB string ''' KB = float(1024) MB = float(KB ** 2) # 1,048,576 GB = float(KB ** 3) # 1,073,741,824 TB = float(KB ** 4) # 1,099,511,627,776 if B < KB: return '{0} B'.fo...
python
def _bytes_to_human(self, B): ''' Return the given bytes as a human friendly KB, MB, GB, or TB string ''' KB = float(1024) MB = float(KB ** 2) # 1,048,576 GB = float(KB ** 3) # 1,073,741,824 TB = float(KB ** 4) # 1,099,511,627,776 if B < KB: return '{0} B'.fo...
[ "def", "_bytes_to_human", "(", "self", ",", "B", ")", ":", "KB", "=", "float", "(", "1024", ")", "MB", "=", "float", "(", "KB", "**", "2", ")", "# 1,048,576", "GB", "=", "float", "(", "KB", "**", "3", ")", "# 1,073,741,824", "TB", "=", "float", "...
Return the given bytes as a human friendly KB, MB, GB, or TB string
[ "Return", "the", "given", "bytes", "as", "a", "human", "friendly", "KB", "MB", "GB", "or", "TB", "string" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L321-L338
17,645
coderholic/pyradio
pyradio/config.py
PyRadioStations.append_station
def append_station(self, params, stationFile=''): """ Append a station to csv file return 0: All ok -2 - playlist not found -3 - negative number specified -4 - number not found -5: Error writing file -6: Error...
python
def append_station(self, params, stationFile=''): """ Append a station to csv file return 0: All ok -2 - playlist not found -3 - negative number specified -4 - number not found -5: Error writing file -6: Error...
[ "def", "append_station", "(", "self", ",", "params", ",", "stationFile", "=", "''", ")", ":", "if", "self", ".", "new_format", ":", "if", "stationFile", ":", "st_file", "=", "stationFile", "else", ":", "st_file", "=", "self", ".", "stations_file", "st_file...
Append a station to csv file return 0: All ok -2 - playlist not found -3 - negative number specified -4 - number not found -5: Error writing file -6: Error renaming file
[ "Append", "a", "station", "to", "csv", "file" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L340-L375
17,646
coderholic/pyradio
pyradio/config.py
PyRadioConfig._check_config_file
def _check_config_file(self, usr): ''' Make sure a config file exists in the config dir ''' package_config_file = path.join(path.dirname(__file__), 'config') user_config_file = path.join(usr, 'config') ''' restore config from bck file ''' if path.exists(user_config_file + '.rest...
python
def _check_config_file(self, usr): ''' Make sure a config file exists in the config dir ''' package_config_file = path.join(path.dirname(__file__), 'config') user_config_file = path.join(usr, 'config') ''' restore config from bck file ''' if path.exists(user_config_file + '.rest...
[ "def", "_check_config_file", "(", "self", ",", "usr", ")", ":", "package_config_file", "=", "path", ".", "join", "(", "path", ".", "dirname", "(", "__file__", ")", ",", "'config'", ")", "user_config_file", "=", "path", ".", "join", "(", "usr", ",", "'con...
Make sure a config file exists in the config dir
[ "Make", "sure", "a", "config", "file", "exists", "in", "the", "config", "dir" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L566-L581
17,647
coderholic/pyradio
pyradio/config.py
PyRadioConfig.save_config
def save_config(self): """ Save config file Creates config.restore (back up file) Returns: -1: Error saving config 0: Config saved successfully 1: Config not saved (not modified""" if not self.opts['dirty_config'][1]: ...
python
def save_config(self): """ Save config file Creates config.restore (back up file) Returns: -1: Error saving config 0: Config saved successfully 1: Config not saved (not modified""" if not self.opts['dirty_config'][1]: ...
[ "def", "save_config", "(", "self", ")", ":", "if", "not", "self", ".", "opts", "[", "'dirty_config'", "]", "[", "1", "]", ":", "if", "logger", ".", "isEnabledFor", "(", "logging", ".", "INFO", ")", ":", "logger", ".", "info", "(", "'Config not saved (n...
Save config file Creates config.restore (back up file) Returns: -1: Error saving config 0: Config saved successfully 1: Config not saved (not modified
[ "Save", "config", "file" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config.py#L639-L773
17,648
coderholic/pyradio
pyradio/radio.py
PyRadio.ctrl_c_handler
def ctrl_c_handler(self, signum, frame): self.ctrl_c_pressed = True if self._cnf.dirty_playlist: """ Try to auto save playlist on exit Do not check result!!! """ self.saveCurrentPlaylist() """ Try to auto save config on exit Do not check result...
python
def ctrl_c_handler(self, signum, frame): self.ctrl_c_pressed = True if self._cnf.dirty_playlist: """ Try to auto save playlist on exit Do not check result!!! """ self.saveCurrentPlaylist() """ Try to auto save config on exit Do not check result...
[ "def", "ctrl_c_handler", "(", "self", ",", "signum", ",", "frame", ")", ":", "self", ".", "ctrl_c_pressed", "=", "True", "if", "self", ".", "_cnf", ".", "dirty_playlist", ":", "\"\"\" Try to auto save playlist on exit\n Do not check result!!! \"\"\"", "se...
Try to auto save config on exit Do not check result!!!
[ "Try", "to", "auto", "save", "config", "on", "exit", "Do", "not", "check", "result!!!" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/radio.py#L432-L440
17,649
coderholic/pyradio
pyradio/radio.py
PyRadio._goto_playing_station
def _goto_playing_station(self, changing_playlist=False): """ make sure playing station is visible """ if (self.player.isPlaying() or self.operation_mode == PLAYLIST_MODE) and \ (self.selection != self.playing or changing_playlist): if changing_playlist: self.star...
python
def _goto_playing_station(self, changing_playlist=False): """ make sure playing station is visible """ if (self.player.isPlaying() or self.operation_mode == PLAYLIST_MODE) and \ (self.selection != self.playing or changing_playlist): if changing_playlist: self.star...
[ "def", "_goto_playing_station", "(", "self", ",", "changing_playlist", "=", "False", ")", ":", "if", "(", "self", ".", "player", ".", "isPlaying", "(", ")", "or", "self", ".", "operation_mode", "==", "PLAYLIST_MODE", ")", "and", "(", "self", ".", "selectio...
make sure playing station is visible
[ "make", "sure", "playing", "station", "is", "visible" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/radio.py#L442-L468
17,650
coderholic/pyradio
pyradio/radio.py
PyRadio.setStation
def setStation(self, number): """ Select the given station number """ # If we press up at the first station, we go to the last one # and if we press down on the last one we go back to the first one. if number < 0: number = len(self.stations) - 1 elif number >= len(sel...
python
def setStation(self, number): """ Select the given station number """ # If we press up at the first station, we go to the last one # and if we press down on the last one we go back to the first one. if number < 0: number = len(self.stations) - 1 elif number >= len(sel...
[ "def", "setStation", "(", "self", ",", "number", ")", ":", "# If we press up at the first station, we go to the last one", "# and if we press down on the last one we go back to the first one.", "if", "number", "<", "0", ":", "number", "=", "len", "(", "self", ".", "stations...
Select the given station number
[ "Select", "the", "given", "station", "number" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/radio.py#L489-L504
17,651
coderholic/pyradio
pyradio/radio.py
PyRadio._format_playlist_line
def _format_playlist_line(self, lineNum, pad, station): """ format playlist line so that if fills self.maxX """ line = "{0}. {1}".format(str(lineNum + self.startPos + 1).rjust(pad), station[0]) f_data = ' [{0}, {1}]'.format(station[2], station[1]) if version_info < (3, 0): if...
python
def _format_playlist_line(self, lineNum, pad, station): """ format playlist line so that if fills self.maxX """ line = "{0}. {1}".format(str(lineNum + self.startPos + 1).rjust(pad), station[0]) f_data = ' [{0}, {1}]'.format(station[2], station[1]) if version_info < (3, 0): if...
[ "def", "_format_playlist_line", "(", "self", ",", "lineNum", ",", "pad", ",", "station", ")", ":", "line", "=", "\"{0}. {1}\"", ".", "format", "(", "str", "(", "lineNum", "+", "self", ".", "startPos", "+", "1", ")", ".", "rjust", "(", "pad", ")", ","...
format playlist line so that if fills self.maxX
[ "format", "playlist", "line", "so", "that", "if", "fills", "self", ".", "maxX" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/radio.py#L772-L805
17,652
coderholic/pyradio
pyradio/config_window.py
PyRadioSelectEncodings._resize
def _resize(self, init=False): col, row = self._selection_to_col_row(self.selection) if not (self.startPos <= row <= self.startPos + self.list_maxY - 1): while row > self.startPos: self.startPos += 1 while row < self.startPos + self.list_maxY - 1: ...
python
def _resize(self, init=False): col, row = self._selection_to_col_row(self.selection) if not (self.startPos <= row <= self.startPos + self.list_maxY - 1): while row > self.startPos: self.startPos += 1 while row < self.startPos + self.list_maxY - 1: ...
[ "def", "_resize", "(", "self", ",", "init", "=", "False", ")", ":", "col", ",", "row", "=", "self", ".", "_selection_to_col_row", "(", "self", ".", "selection", ")", "if", "not", "(", "self", ".", "startPos", "<=", "row", "<=", "self", ".", "startPos...
if the selection at the end of the list, try to scroll down
[ "if", "the", "selection", "at", "the", "end", "of", "the", "list", "try", "to", "scroll", "down" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/config_window.py#L745-L760
17,653
coderholic/pyradio
pyradio/simple_curses_widgets.py
SimpleCursesLineEdit._get_char
def _get_char(self, win, char): def get_check_next_byte(): char = win.getch() if 128 <= char <= 191: return char else: raise UnicodeError bytes = [] if char <= 127: # 1 bytes bytes.append(char) #...
python
def _get_char(self, win, char): def get_check_next_byte(): char = win.getch() if 128 <= char <= 191: return char else: raise UnicodeError bytes = [] if char <= 127: # 1 bytes bytes.append(char) #...
[ "def", "_get_char", "(", "self", ",", "win", ",", "char", ")", ":", "def", "get_check_next_byte", "(", ")", ":", "char", "=", "win", ".", "getch", "(", ")", "if", "128", "<=", "char", "<=", "191", ":", "return", "char", "else", ":", "raise", "Unico...
no zero byte allowed
[ "no", "zero", "byte", "allowed" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/simple_curses_widgets.py#L342-L380
17,654
coderholic/pyradio
pyradio/edit.py
PyRadioSearch._get_history_next
def _get_history_next(self): """ callback function for key down """ if self._has_history: ret = self._input_history.return_history(1) self.string = ret self._curs_pos = len(ret)
python
def _get_history_next(self): """ callback function for key down """ if self._has_history: ret = self._input_history.return_history(1) self.string = ret self._curs_pos = len(ret)
[ "def", "_get_history_next", "(", "self", ")", ":", "if", "self", ".", "_has_history", ":", "ret", "=", "self", ".", "_input_history", ".", "return_history", "(", "1", ")", "self", ".", "string", "=", "ret", "self", ".", "_curs_pos", "=", "len", "(", "r...
callback function for key down
[ "callback", "function", "for", "key", "down" ]
c5219d350bccbccd49dbd627c1f886a952ea1963
https://github.com/coderholic/pyradio/blob/c5219d350bccbccd49dbd627c1f886a952ea1963/pyradio/edit.py#L49-L54
17,655
bids-standard/pybids
bids/analysis/analysis.py
apply_transformations
def apply_transformations(collection, transformations, select=None): ''' Apply all transformations to the variables in the collection. Args: transformations (list): List of transformations to apply. select (list): Optional list of names of variables to retain after all transformatio...
python
def apply_transformations(collection, transformations, select=None): ''' Apply all transformations to the variables in the collection. Args: transformations (list): List of transformations to apply. select (list): Optional list of names of variables to retain after all transformatio...
[ "def", "apply_transformations", "(", "collection", ",", "transformations", ",", "select", "=", "None", ")", ":", "for", "t", "in", "transformations", ":", "kwargs", "=", "dict", "(", "t", ")", "func", "=", "kwargs", ".", "pop", "(", "'name'", ")", "cols"...
Apply all transformations to the variables in the collection. Args: transformations (list): List of transformations to apply. select (list): Optional list of names of variables to retain after all transformations are applied.
[ "Apply", "all", "transformations", "to", "the", "variables", "in", "the", "collection", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/analysis.py#L489-L513
17,656
bids-standard/pybids
bids/analysis/analysis.py
Analysis.setup
def setup(self, steps=None, drop_na=False, **kwargs): ''' Set up the sequence of steps for analysis. Args: steps (list): Optional list of steps to set up. Each element must be either an int giving the index of the step in the JSON config block list, or a str ...
python
def setup(self, steps=None, drop_na=False, **kwargs): ''' Set up the sequence of steps for analysis. Args: steps (list): Optional list of steps to set up. Each element must be either an int giving the index of the step in the JSON config block list, or a str ...
[ "def", "setup", "(", "self", ",", "steps", "=", "None", ",", "drop_na", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# In the beginning, there was nothing", "input_nodes", "=", "None", "# Use inputs from model, and update with kwargs", "selectors", "=", "self",...
Set up the sequence of steps for analysis. Args: steps (list): Optional list of steps to set up. Each element must be either an int giving the index of the step in the JSON config block list, or a str giving the (unique) name of the step, as specified...
[ "Set", "up", "the", "sequence", "of", "steps", "for", "analysis", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/analysis.py#L62-L90
17,657
bids-standard/pybids
bids/analysis/analysis.py
Step.setup
def setup(self, input_nodes=None, drop_na=False, **kwargs): ''' Set up the Step and construct the design matrix. Args: input_nodes (list): Optional list of Node objects produced by the preceding Step in the analysis. If None, uses any inputs passed in at Step...
python
def setup(self, input_nodes=None, drop_na=False, **kwargs): ''' Set up the Step and construct the design matrix. Args: input_nodes (list): Optional list of Node objects produced by the preceding Step in the analysis. If None, uses any inputs passed in at Step...
[ "def", "setup", "(", "self", ",", "input_nodes", "=", "None", ",", "drop_na", "=", "False", ",", "*", "*", "kwargs", ")", ":", "self", ".", "output_nodes", "=", "[", "]", "input_nodes", "=", "input_nodes", "or", "self", ".", "input_nodes", "or", "[", ...
Set up the Step and construct the design matrix. Args: input_nodes (list): Optional list of Node objects produced by the preceding Step in the analysis. If None, uses any inputs passed in at Step initialization. drop_na (bool): Boolean indicating whether ...
[ "Set", "up", "the", "Step", "and", "construct", "the", "design", "matrix", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/analysis.py#L168-L218
17,658
bids-standard/pybids
bids/reports/utils.py
get_slice_info
def get_slice_info(slice_times): """ Extract slice order from slice timing info. TODO: Be more specific with slice orders. Currently anything where there's some kind of skipping is interpreted as interleaved of some kind. Parameters ---------- slice_times : array-like A list of...
python
def get_slice_info(slice_times): """ Extract slice order from slice timing info. TODO: Be more specific with slice orders. Currently anything where there's some kind of skipping is interpreted as interleaved of some kind. Parameters ---------- slice_times : array-like A list of...
[ "def", "get_slice_info", "(", "slice_times", ")", ":", "# Slice order", "slice_times", "=", "remove_duplicates", "(", "slice_times", ")", "slice_order", "=", "sorted", "(", "range", "(", "len", "(", "slice_times", ")", ")", ",", "key", "=", "lambda", "k", ":...
Extract slice order from slice timing info. TODO: Be more specific with slice orders. Currently anything where there's some kind of skipping is interpreted as interleaved of some kind. Parameters ---------- slice_times : array-like A list of slice times in seconds or milliseconds or wh...
[ "Extract", "slice", "order", "from", "slice", "timing", "info", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/utils.py#L70-L104
17,659
bids-standard/pybids
bids/reports/utils.py
get_sizestr
def get_sizestr(img): """ Extract and reformat voxel size, matrix size, field of view, and number of slices into pretty strings. Parameters ---------- img : :obj:`nibabel.Nifti1Image` Image from scan from which to derive parameters. Returns ------- n_slices : :obj:`int` ...
python
def get_sizestr(img): """ Extract and reformat voxel size, matrix size, field of view, and number of slices into pretty strings. Parameters ---------- img : :obj:`nibabel.Nifti1Image` Image from scan from which to derive parameters. Returns ------- n_slices : :obj:`int` ...
[ "def", "get_sizestr", "(", "img", ")", ":", "n_x", ",", "n_y", ",", "n_slices", "=", "img", ".", "shape", "[", ":", "3", "]", "import", "numpy", "as", "np", "voxel_dims", "=", "np", ".", "array", "(", "img", ".", "header", ".", "get_zooms", "(", ...
Extract and reformat voxel size, matrix size, field of view, and number of slices into pretty strings. Parameters ---------- img : :obj:`nibabel.Nifti1Image` Image from scan from which to derive parameters. Returns ------- n_slices : :obj:`int` Number of slices. voxel_s...
[ "Extract", "and", "reformat", "voxel", "size", "matrix", "size", "field", "of", "view", "and", "number", "of", "slices", "into", "pretty", "strings", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/utils.py#L138-L166
17,660
bids-standard/pybids
bids/layout/layout.py
add_config_paths
def add_config_paths(**kwargs): """ Add to the pool of available configuration files for BIDSLayout. Args: kwargs: dictionary specifying where to find additional config files. Keys are names, values are paths to the corresponding .json file. Example: > add_config_paths(my_confi...
python
def add_config_paths(**kwargs): """ Add to the pool of available configuration files for BIDSLayout. Args: kwargs: dictionary specifying where to find additional config files. Keys are names, values are paths to the corresponding .json file. Example: > add_config_paths(my_confi...
[ "def", "add_config_paths", "(", "*", "*", "kwargs", ")", ":", "for", "k", ",", "path", "in", "kwargs", ".", "items", "(", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "ValueError", "(", "'Configuration file...
Add to the pool of available configuration files for BIDSLayout. Args: kwargs: dictionary specifying where to find additional config files. Keys are names, values are paths to the corresponding .json file. Example: > add_config_paths(my_config='/path/to/config') > layout = ...
[ "Add", "to", "the", "pool", "of", "available", "configuration", "files", "for", "BIDSLayout", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L77-L97
17,661
bids-standard/pybids
bids/layout/layout.py
BIDSLayout.add_derivatives
def add_derivatives(self, path, **kwargs): ''' Add BIDS-Derivatives datasets to tracking. Args: path (str, list): One or more paths to BIDS-Derivatives datasets. Each path can point to either a derivatives/ directory containing one more more pipeline director...
python
def add_derivatives(self, path, **kwargs): ''' Add BIDS-Derivatives datasets to tracking. Args: path (str, list): One or more paths to BIDS-Derivatives datasets. Each path can point to either a derivatives/ directory containing one more more pipeline director...
[ "def", "add_derivatives", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "paths", "=", "listify", "(", "path", ")", "deriv_dirs", "=", "[", "]", "# Collect all paths that contain a dataset_description.json", "def", "check_for_description", "(", "dir"...
Add BIDS-Derivatives datasets to tracking. Args: path (str, list): One or more paths to BIDS-Derivatives datasets. Each path can point to either a derivatives/ directory containing one more more pipeline directories, or to a single pipeline directory ...
[ "Add", "BIDS", "-", "Derivatives", "datasets", "to", "tracking", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L352-L418
17,662
bids-standard/pybids
bids/layout/layout.py
BIDSLayout.get_file
def get_file(self, filename, scope='all'): ''' Returns the BIDSFile object with the specified path. Args: filename (str): The path of the file to retrieve. Must be either an absolute path, or relative to the root of this BIDSLayout. scope (str, list): Scope of th...
python
def get_file(self, filename, scope='all'): ''' Returns the BIDSFile object with the specified path. Args: filename (str): The path of the file to retrieve. Must be either an absolute path, or relative to the root of this BIDSLayout. scope (str, list): Scope of th...
[ "def", "get_file", "(", "self", ",", "filename", ",", "scope", "=", "'all'", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "self", ".", "root", ",", "filename", ")", ")", "layouts", "=", "...
Returns the BIDSFile object with the specified path. Args: filename (str): The path of the file to retrieve. Must be either an absolute path, or relative to the root of this BIDSLayout. scope (str, list): Scope of the search space. If passed, only BIDSLay...
[ "Returns", "the", "BIDSFile", "object", "with", "the", "specified", "path", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L600-L617
17,663
bids-standard/pybids
bids/layout/layout.py
BIDSLayout.get_collections
def get_collections(self, level, types=None, variables=None, merge=False, sampling_rate=None, skip_empty=False, **kwargs): """Return one or more variable Collections in the BIDS project. Args: level (str): The level of analysis to return variables for. Must be ...
python
def get_collections(self, level, types=None, variables=None, merge=False, sampling_rate=None, skip_empty=False, **kwargs): """Return one or more variable Collections in the BIDS project. Args: level (str): The level of analysis to return variables for. Must be ...
[ "def", "get_collections", "(", "self", ",", "level", ",", "types", "=", "None", ",", "variables", "=", "None", ",", "merge", "=", "False", ",", "sampling_rate", "=", "None", ",", "skip_empty", "=", "False", ",", "*", "*", "kwargs", ")", ":", "from", ...
Return one or more variable Collections in the BIDS project. Args: level (str): The level of analysis to return variables for. Must be one of 'run', 'session', 'subject', or 'dataset'. types (str, list): Types of variables to retrieve. All valid values reflec...
[ "Return", "one", "or", "more", "variable", "Collections", "in", "the", "BIDS", "project", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L619-L648
17,664
bids-standard/pybids
bids/layout/layout.py
BIDSLayout.get_metadata
def get_metadata(self, path, include_entities=False, **kwargs): """Return metadata found in JSON sidecars for the specified file. Args: path (str): Path to the file to get metadata for. include_entities (bool): If True, all available entities extracted from the f...
python
def get_metadata(self, path, include_entities=False, **kwargs): """Return metadata found in JSON sidecars for the specified file. Args: path (str): Path to the file to get metadata for. include_entities (bool): If True, all available entities extracted from the f...
[ "def", "get_metadata", "(", "self", ",", "path", ",", "include_entities", "=", "False", ",", "*", "*", "kwargs", ")", ":", "f", "=", "self", ".", "get_file", "(", "path", ")", "# For querying efficiency, store metadata in the MetadataIndex cache", "self", ".", "...
Return metadata found in JSON sidecars for the specified file. Args: path (str): Path to the file to get metadata for. include_entities (bool): If True, all available entities extracted from the filename (rather than JSON sidecars) are included in the ret...
[ "Return", "metadata", "found", "in", "JSON", "sidecars", "for", "the", "specified", "file", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L650-L684
17,665
bids-standard/pybids
bids/layout/layout.py
BIDSLayout.get_bval
def get_bval(self, path, **kwargs): """ Get bval file for passed path. """ result = self.get_nearest(path, extensions='bval', suffix='dwi', all_=True, **kwargs) return listify(result)[0]
python
def get_bval(self, path, **kwargs): """ Get bval file for passed path. """ result = self.get_nearest(path, extensions='bval', suffix='dwi', all_=True, **kwargs) return listify(result)[0]
[ "def", "get_bval", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "result", "=", "self", ".", "get_nearest", "(", "path", ",", "extensions", "=", "'bval'", ",", "suffix", "=", "'dwi'", ",", "all_", "=", "True", ",", "*", "*", "kwargs"...
Get bval file for passed path.
[ "Get", "bval", "file", "for", "passed", "path", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L794-L798
17,666
bids-standard/pybids
bids/layout/layout.py
BIDSLayout.copy_files
def copy_files(self, files=None, path_patterns=None, symbolic_links=True, root=None, conflicts='fail', **kwargs): """ Copies one or more BIDSFiles to new locations defined by each BIDSFile's entities and the specified path_patterns. Args: files (list): Opt...
python
def copy_files(self, files=None, path_patterns=None, symbolic_links=True, root=None, conflicts='fail', **kwargs): """ Copies one or more BIDSFiles to new locations defined by each BIDSFile's entities and the specified path_patterns. Args: files (list): Opt...
[ "def", "copy_files", "(", "self", ",", "files", "=", "None", ",", "path_patterns", "=", "None", ",", "symbolic_links", "=", "True", ",", "root", "=", "None", ",", "conflicts", "=", "'fail'", ",", "*", "*", "kwargs", ")", ":", "_files", "=", "self", "...
Copies one or more BIDSFiles to new locations defined by each BIDSFile's entities and the specified path_patterns. Args: files (list): Optional list of BIDSFile objects to write out. If none provided, use files from running a get() query using remaining **kwa...
[ "Copies", "one", "or", "more", "BIDSFiles", "to", "new", "locations", "defined", "by", "each", "BIDSFile", "s", "entities", "and", "the", "specified", "path_patterns", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L950-L981
17,667
bids-standard/pybids
bids/layout/layout.py
MetadataIndex.index_file
def index_file(self, f, overwrite=False): """Index metadata for the specified file. Args: f (BIDSFile, str): A BIDSFile or path to an indexed file. overwrite (bool): If True, forces reindexing of the file even if an entry already exists. """ if is...
python
def index_file(self, f, overwrite=False): """Index metadata for the specified file. Args: f (BIDSFile, str): A BIDSFile or path to an indexed file. overwrite (bool): If True, forces reindexing of the file even if an entry already exists. """ if is...
[ "def", "index_file", "(", "self", ",", "f", ",", "overwrite", "=", "False", ")", ":", "if", "isinstance", "(", "f", ",", "six", ".", "string_types", ")", ":", "f", "=", "self", ".", "layout", ".", "get_file", "(", "f", ")", "if", "f", ".", "path"...
Index metadata for the specified file. Args: f (BIDSFile, str): A BIDSFile or path to an indexed file. overwrite (bool): If True, forces reindexing of the file even if an entry already exists.
[ "Index", "metadata", "for", "the", "specified", "file", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L1036-L1059
17,668
bids-standard/pybids
bids/layout/layout.py
MetadataIndex.search
def search(self, files=None, defined_fields=None, **kwargs): """Search files in the layout by metadata fields. Args: files (list): Optional list of names of files to search. If None, all files in the layout are scanned. defined_fields (list): Optional list of nam...
python
def search(self, files=None, defined_fields=None, **kwargs): """Search files in the layout by metadata fields. Args: files (list): Optional list of names of files to search. If None, all files in the layout are scanned. defined_fields (list): Optional list of nam...
[ "def", "search", "(", "self", ",", "files", "=", "None", ",", "defined_fields", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "defined_fields", "is", "None", ":", "defined_fields", "=", "[", "]", "all_keys", "=", "set", "(", "defined_fields", "...
Search files in the layout by metadata fields. Args: files (list): Optional list of names of files to search. If None, all files in the layout are scanned. defined_fields (list): Optional list of names of fields that must be defined in the JSON sidecar in...
[ "Search", "files", "in", "the", "layout", "by", "metadata", "fields", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/layout.py#L1080-L1136
17,669
bids-standard/pybids
bids/analysis/auto_model.py
auto_model
def auto_model(layout, scan_length=None, one_vs_rest=False): '''Create a simple default model for each of the tasks in a BIDSLayout. Contrasts each trial type against all other trial types and trial types at the run level and then uses t-tests at each other level present to aggregate these results up. ...
python
def auto_model(layout, scan_length=None, one_vs_rest=False): '''Create a simple default model for each of the tasks in a BIDSLayout. Contrasts each trial type against all other trial types and trial types at the run level and then uses t-tests at each other level present to aggregate these results up. ...
[ "def", "auto_model", "(", "layout", ",", "scan_length", "=", "None", ",", "one_vs_rest", "=", "False", ")", ":", "base_name", "=", "split", "(", "layout", ".", "root", ")", "[", "-", "1", "]", "tasks", "=", "layout", ".", "entities", "[", "'task'", "...
Create a simple default model for each of the tasks in a BIDSLayout. Contrasts each trial type against all other trial types and trial types at the run level and then uses t-tests at each other level present to aggregate these results up. Args: layout (BIDSLayout) A BIDSLayout instance ...
[ "Create", "a", "simple", "default", "model", "for", "each", "of", "the", "tasks", "in", "a", "BIDSLayout", ".", "Contrasts", "each", "trial", "type", "against", "all", "other", "trial", "types", "and", "trial", "types", "at", "the", "run", "level", "and", ...
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/auto_model.py#L19-L122
17,670
bids-standard/pybids
bids/variables/variables.py
SimpleVariable.split
def split(self, grouper): ''' Split the current SparseRunVariable into multiple columns. Args: grouper (iterable): list to groupby, where each unique value will be taken as the name of the resulting column. Returns: A list of SparseRunVariables, one per ...
python
def split(self, grouper): ''' Split the current SparseRunVariable into multiple columns. Args: grouper (iterable): list to groupby, where each unique value will be taken as the name of the resulting column. Returns: A list of SparseRunVariables, one per ...
[ "def", "split", "(", "self", ",", "grouper", ")", ":", "data", "=", "self", ".", "to_df", "(", "condition", "=", "True", ",", "entities", "=", "True", ")", "data", "=", "data", ".", "drop", "(", "'condition'", ",", "axis", "=", "1", ")", "subsets",...
Split the current SparseRunVariable into multiple columns. Args: grouper (iterable): list to groupby, where each unique value will be taken as the name of the resulting column. Returns: A list of SparseRunVariables, one per unique value in the groupe...
[ "Split", "the", "current", "SparseRunVariable", "into", "multiple", "columns", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L240-L260
17,671
bids-standard/pybids
bids/variables/variables.py
SimpleVariable.select_rows
def select_rows(self, rows): ''' Truncate internal arrays to keep only the specified rows. Args: rows (array): An integer or boolean array identifying the indices of rows to keep. ''' self.values = self.values.iloc[rows] self.index = self.index.iloc[r...
python
def select_rows(self, rows): ''' Truncate internal arrays to keep only the specified rows. Args: rows (array): An integer or boolean array identifying the indices of rows to keep. ''' self.values = self.values.iloc[rows] self.index = self.index.iloc[r...
[ "def", "select_rows", "(", "self", ",", "rows", ")", ":", "self", ".", "values", "=", "self", ".", "values", ".", "iloc", "[", "rows", "]", "self", ".", "index", "=", "self", ".", "index", ".", "iloc", "[", "rows", ",", ":", "]", "for", "prop", ...
Truncate internal arrays to keep only the specified rows. Args: rows (array): An integer or boolean array identifying the indices of rows to keep.
[ "Truncate", "internal", "arrays", "to", "keep", "only", "the", "specified", "rows", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L269-L280
17,672
bids-standard/pybids
bids/variables/variables.py
DenseRunVariable.split
def split(self, grouper): '''Split the current DenseRunVariable into multiple columns. Parameters ---------- grouper : :obj:`pandas.DataFrame` Binary DF specifying the design matrix to use for splitting. Number of rows must match current ``DenseRunVariable``; a n...
python
def split(self, grouper): '''Split the current DenseRunVariable into multiple columns. Parameters ---------- grouper : :obj:`pandas.DataFrame` Binary DF specifying the design matrix to use for splitting. Number of rows must match current ``DenseRunVariable``; a n...
[ "def", "split", "(", "self", ",", "grouper", ")", ":", "values", "=", "grouper", ".", "values", "*", "self", ".", "values", ".", "values", "df", "=", "pd", ".", "DataFrame", "(", "values", ",", "columns", "=", "grouper", ".", "columns", ")", "return"...
Split the current DenseRunVariable into multiple columns. Parameters ---------- grouper : :obj:`pandas.DataFrame` Binary DF specifying the design matrix to use for splitting. Number of rows must match current ``DenseRunVariable``; a new ``DenseRunVariable`` w...
[ "Split", "the", "current", "DenseRunVariable", "into", "multiple", "columns", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L393-L414
17,673
bids-standard/pybids
bids/variables/variables.py
DenseRunVariable._build_entity_index
def _build_entity_index(self, run_info, sampling_rate): ''' Build the entity index from run information. ''' index = [] interval = int(round(1000. / sampling_rate)) _timestamps = [] for run in run_info: reps = int(math.ceil(run.duration * sampling_rate)) ...
python
def _build_entity_index(self, run_info, sampling_rate): ''' Build the entity index from run information. ''' index = [] interval = int(round(1000. / sampling_rate)) _timestamps = [] for run in run_info: reps = int(math.ceil(run.duration * sampling_rate)) ...
[ "def", "_build_entity_index", "(", "self", ",", "run_info", ",", "sampling_rate", ")", ":", "index", "=", "[", "]", "interval", "=", "int", "(", "round", "(", "1000.", "/", "sampling_rate", ")", ")", "_timestamps", "=", "[", "]", "for", "run", "in", "r...
Build the entity index from run information.
[ "Build", "the", "entity", "index", "from", "run", "information", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L416-L430
17,674
bids-standard/pybids
bids/variables/variables.py
DenseRunVariable.resample
def resample(self, sampling_rate, inplace=False, kind='linear'): '''Resample the Variable to the specified sampling rate. Parameters ---------- sampling_rate : :obj:`int`, :obj:`float` Target sampling rate (in Hz). inplace : :obj:`bool`, optional If True,...
python
def resample(self, sampling_rate, inplace=False, kind='linear'): '''Resample the Variable to the specified sampling rate. Parameters ---------- sampling_rate : :obj:`int`, :obj:`float` Target sampling rate (in Hz). inplace : :obj:`bool`, optional If True,...
[ "def", "resample", "(", "self", ",", "sampling_rate", ",", "inplace", "=", "False", ",", "kind", "=", "'linear'", ")", ":", "if", "not", "inplace", ":", "var", "=", "self", ".", "clone", "(", ")", "var", ".", "resample", "(", "sampling_rate", ",", "T...
Resample the Variable to the specified sampling rate. Parameters ---------- sampling_rate : :obj:`int`, :obj:`float` Target sampling rate (in Hz). inplace : :obj:`bool`, optional If True, performs resampling in-place. If False, returns a resampled cop...
[ "Resample", "the", "Variable", "to", "the", "specified", "sampling", "rate", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L432-L469
17,675
bids-standard/pybids
bids/variables/variables.py
DenseRunVariable.to_df
def to_df(self, condition=True, entities=True, timing=True, sampling_rate=None): '''Convert to a DataFrame, with columns for name and entities. Parameters ---------- condition : :obj:`bool` If True, adds a column for condition name, and names the amplitude column...
python
def to_df(self, condition=True, entities=True, timing=True, sampling_rate=None): '''Convert to a DataFrame, with columns for name and entities. Parameters ---------- condition : :obj:`bool` If True, adds a column for condition name, and names the amplitude column...
[ "def", "to_df", "(", "self", ",", "condition", "=", "True", ",", "entities", "=", "True", ",", "timing", "=", "True", ",", "sampling_rate", "=", "None", ")", ":", "if", "sampling_rate", "not", "in", "(", "None", ",", "self", ".", "sampling_rate", ")", ...
Convert to a DataFrame, with columns for name and entities. Parameters ---------- condition : :obj:`bool` If True, adds a column for condition name, and names the amplitude column 'amplitude'. If False, returns just onset, duration, and amplitude, and gives t...
[ "Convert", "to", "a", "DataFrame", "with", "columns", "for", "name", "and", "entities", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L471-L495
17,676
bids-standard/pybids
bids/variables/entities.py
NodeIndex.get_collections
def get_collections(self, unit, names=None, merge=False, sampling_rate=None, **entities): ''' Retrieve variable data for a specified level in the Dataset. Args: unit (str): The unit of analysis to return variables for. Must be one of 'run', 'session',...
python
def get_collections(self, unit, names=None, merge=False, sampling_rate=None, **entities): ''' Retrieve variable data for a specified level in the Dataset. Args: unit (str): The unit of analysis to return variables for. Must be one of 'run', 'session',...
[ "def", "get_collections", "(", "self", ",", "unit", ",", "names", "=", "None", ",", "merge", "=", "False", ",", "sampling_rate", "=", "None", ",", "*", "*", "entities", ")", ":", "nodes", "=", "self", ".", "get_nodes", "(", "unit", ",", "entities", "...
Retrieve variable data for a specified level in the Dataset. Args: unit (str): The unit of analysis to return variables for. Must be one of 'run', 'session', 'subject', or 'dataset'. names (list): Optional list of variables names to return. If None, all a...
[ "Retrieve", "variable", "data", "for", "a", "specified", "level", "in", "the", "Dataset", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/entities.py#L65-L118
17,677
bids-standard/pybids
bids/variables/entities.py
NodeIndex.get_or_create_node
def get_or_create_node(self, level, entities, *args, **kwargs): ''' Retrieves a child Node based on the specified criteria, creating a new Node if necessary. Args: entities (dict): Dictionary of entities specifying which Node to return. args, kwargs: Opti...
python
def get_or_create_node(self, level, entities, *args, **kwargs): ''' Retrieves a child Node based on the specified criteria, creating a new Node if necessary. Args: entities (dict): Dictionary of entities specifying which Node to return. args, kwargs: Opti...
[ "def", "get_or_create_node", "(", "self", ",", "level", ",", "entities", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "self", ".", "get_nodes", "(", "level", ",", "entities", ")", "if", "result", ":", "if", "len", "(", "result"...
Retrieves a child Node based on the specified criteria, creating a new Node if necessary. Args: entities (dict): Dictionary of entities specifying which Node to return. args, kwargs: Optional positional or named arguments to pass onto class-specif...
[ "Retrieves", "a", "child", "Node", "based", "on", "the", "specified", "criteria", "creating", "a", "new", "Node", "if", "necessary", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/entities.py#L160-L198
17,678
bids-standard/pybids
bids/variables/kollekshuns.py
merge_collections
def merge_collections(collections, force_dense=False, sampling_rate='auto'): ''' Merge two or more collections at the same level of analysis. Args: collections (list): List of Collections to merge. sampling_rate (int, str): Sampling rate to use if it becomes necessary to resample De...
python
def merge_collections(collections, force_dense=False, sampling_rate='auto'): ''' Merge two or more collections at the same level of analysis. Args: collections (list): List of Collections to merge. sampling_rate (int, str): Sampling rate to use if it becomes necessary to resample De...
[ "def", "merge_collections", "(", "collections", ",", "force_dense", "=", "False", ",", "sampling_rate", "=", "'auto'", ")", ":", "if", "len", "(", "listify", "(", "collections", ")", ")", "==", "1", ":", "return", "collections", "levels", "=", "set", "(", ...
Merge two or more collections at the same level of analysis. Args: collections (list): List of Collections to merge. sampling_rate (int, str): Sampling rate to use if it becomes necessary to resample DenseRunVariables. Either an integer or 'auto' (see merge_variables docstri...
[ "Merge", "two", "or", "more", "collections", "at", "the", "same", "level", "of", "analysis", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L354-L390
17,679
bids-standard/pybids
bids/variables/kollekshuns.py
BIDSVariableCollection.merge_variables
def merge_variables(variables, **kwargs): ''' Concatenates Variables along row axis. Args: variables (list): List of Variables to merge. Variables can have different names (and all Variables that share a name will be concatenated together). Returns: ...
python
def merge_variables(variables, **kwargs): ''' Concatenates Variables along row axis. Args: variables (list): List of Variables to merge. Variables can have different names (and all Variables that share a name will be concatenated together). Returns: ...
[ "def", "merge_variables", "(", "variables", ",", "*", "*", "kwargs", ")", ":", "var_dict", "=", "OrderedDict", "(", ")", "for", "v", "in", "variables", ":", "if", "v", ".", "name", "not", "in", "var_dict", ":", "var_dict", "[", "v", ".", "name", "]",...
Concatenates Variables along row axis. Args: variables (list): List of Variables to merge. Variables can have different names (and all Variables that share a name will be concatenated together). Returns: A list of Variables.
[ "Concatenates", "Variables", "along", "row", "axis", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L69-L86
17,680
bids-standard/pybids
bids/variables/kollekshuns.py
BIDSVariableCollection.to_df
def to_df(self, variables=None, format='wide', fillna=np.nan, **kwargs): ''' Merge variables into a single pandas DataFrame. Args: variables (list): Optional list of column names to retain; if None, all variables are returned. format (str): Whether to return a Da...
python
def to_df(self, variables=None, format='wide', fillna=np.nan, **kwargs): ''' Merge variables into a single pandas DataFrame. Args: variables (list): Optional list of column names to retain; if None, all variables are returned. format (str): Whether to return a Da...
[ "def", "to_df", "(", "self", ",", "variables", "=", "None", ",", "format", "=", "'wide'", ",", "fillna", "=", "np", ".", "nan", ",", "*", "*", "kwargs", ")", ":", "if", "variables", "is", "None", ":", "variables", "=", "list", "(", "self", ".", "...
Merge variables into a single pandas DataFrame. Args: variables (list): Optional list of column names to retain; if None, all variables are returned. format (str): Whether to return a DataFrame in 'wide' or 'long' format. In 'wide' format, each row is def...
[ "Merge", "variables", "into", "a", "single", "pandas", "DataFrame", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L88-L128
17,681
bids-standard/pybids
bids/variables/kollekshuns.py
BIDSVariableCollection.from_df
def from_df(cls, data, entities=None, source='contrast'): ''' Create a Collection from a pandas DataFrame. Args: df (DataFrame): The DataFrame to convert to a Collection. Each column will be converted to a SimpleVariable. entities (DataFrame): An optional second ...
python
def from_df(cls, data, entities=None, source='contrast'): ''' Create a Collection from a pandas DataFrame. Args: df (DataFrame): The DataFrame to convert to a Collection. Each column will be converted to a SimpleVariable. entities (DataFrame): An optional second ...
[ "def", "from_df", "(", "cls", ",", "data", ",", "entities", "=", "None", ",", "source", "=", "'contrast'", ")", ":", "variables", "=", "[", "]", "for", "col", "in", "data", ".", "columns", ":", "_data", "=", "pd", ".", "DataFrame", "(", "data", "["...
Create a Collection from a pandas DataFrame. Args: df (DataFrame): The DataFrame to convert to a Collection. Each column will be converted to a SimpleVariable. entities (DataFrame): An optional second DataFrame containing entity information. s...
[ "Create", "a", "Collection", "from", "a", "pandas", "DataFrame", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L131-L150
17,682
bids-standard/pybids
bids/variables/kollekshuns.py
BIDSVariableCollection.clone
def clone(self): ''' Returns a shallow copy of the current instance, except that all variables are deep-cloned. ''' clone = copy(self) clone.variables = {k: v.clone() for (k, v) in self.variables.items()} return clone
python
def clone(self): ''' Returns a shallow copy of the current instance, except that all variables are deep-cloned. ''' clone = copy(self) clone.variables = {k: v.clone() for (k, v) in self.variables.items()} return clone
[ "def", "clone", "(", "self", ")", ":", "clone", "=", "copy", "(", "self", ")", "clone", ".", "variables", "=", "{", "k", ":", "v", ".", "clone", "(", ")", "for", "(", "k", ",", "v", ")", "in", "self", ".", "variables", ".", "items", "(", ")",...
Returns a shallow copy of the current instance, except that all variables are deep-cloned.
[ "Returns", "a", "shallow", "copy", "of", "the", "current", "instance", "except", "that", "all", "variables", "are", "deep", "-", "cloned", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L152-L158
17,683
bids-standard/pybids
bids/variables/kollekshuns.py
BIDSVariableCollection._index_entities
def _index_entities(self): ''' Sets current instance's entities based on the existing index. Note: Only entity key/value pairs common to all rows in all contained Variables are returned. E.g., if a Collection contains Variables extracted from runs 1, 2 and 3 from subject '01', t...
python
def _index_entities(self): ''' Sets current instance's entities based on the existing index. Note: Only entity key/value pairs common to all rows in all contained Variables are returned. E.g., if a Collection contains Variables extracted from runs 1, 2 and 3 from subject '01', t...
[ "def", "_index_entities", "(", "self", ")", ":", "all_ents", "=", "pd", ".", "DataFrame", ".", "from_records", "(", "[", "v", ".", "entities", "for", "v", "in", "self", ".", "variables", ".", "values", "(", ")", "]", ")", "constant", "=", "all_ents", ...
Sets current instance's entities based on the existing index. Note: Only entity key/value pairs common to all rows in all contained Variables are returned. E.g., if a Collection contains Variables extracted from runs 1, 2 and 3 from subject '01', the returned dict will be {'...
[ "Sets", "current", "instance", "s", "entities", "based", "on", "the", "existing", "index", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L164-L181
17,684
bids-standard/pybids
bids/variables/kollekshuns.py
BIDSVariableCollection.match_variables
def match_variables(self, pattern, return_type='name'): ''' Return columns whose names match the provided regex pattern. Args: pattern (str): A regex pattern to match all variable names against. return_type (str): What to return. Must be one of: 'name': Returns a...
python
def match_variables(self, pattern, return_type='name'): ''' Return columns whose names match the provided regex pattern. Args: pattern (str): A regex pattern to match all variable names against. return_type (str): What to return. Must be one of: 'name': Returns a...
[ "def", "match_variables", "(", "self", ",", "pattern", ",", "return_type", "=", "'name'", ")", ":", "pattern", "=", "re", ".", "compile", "(", "pattern", ")", "vars_", "=", "[", "v", "for", "v", "in", "self", ".", "variables", ".", "values", "(", ")"...
Return columns whose names match the provided regex pattern. Args: pattern (str): A regex pattern to match all variable names against. return_type (str): What to return. Must be one of: 'name': Returns a list of names of matching variables. 'variable': Re...
[ "Return", "columns", "whose", "names", "match", "the", "provided", "regex", "pattern", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L196-L209
17,685
bids-standard/pybids
bids/variables/kollekshuns.py
BIDSRunVariableCollection.to_df
def to_df(self, variables=None, format='wide', sparse=True, sampling_rate=None, include_sparse=True, include_dense=True, **kwargs): ''' Merge columns into a single pandas DataFrame. Args: variables (list): Optional list of variable names to retain; ...
python
def to_df(self, variables=None, format='wide', sparse=True, sampling_rate=None, include_sparse=True, include_dense=True, **kwargs): ''' Merge columns into a single pandas DataFrame. Args: variables (list): Optional list of variable names to retain; ...
[ "def", "to_df", "(", "self", ",", "variables", "=", "None", ",", "format", "=", "'wide'", ",", "sparse", "=", "True", ",", "sampling_rate", "=", "None", ",", "include_sparse", "=", "True", ",", "include_dense", "=", "True", ",", "*", "*", "kwargs", ")"...
Merge columns into a single pandas DataFrame. Args: variables (list): Optional list of variable names to retain; if None, all variables are written out. format (str): Whether to return a DataFrame in 'wide' or 'long' format. In 'wide' format, each row is ...
[ "Merge", "columns", "into", "a", "single", "pandas", "DataFrame", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L290-L351
17,686
bids-standard/pybids
bids/analysis/transformations/munge.py
Rename._transform
def _transform(self, var): ''' Rename happens automatically in the base class, so all we need to do is unset the original variable in the collection. ''' self.collection.variables.pop(var.name) return var.values
python
def _transform(self, var): ''' Rename happens automatically in the base class, so all we need to do is unset the original variable in the collection. ''' self.collection.variables.pop(var.name) return var.values
[ "def", "_transform", "(", "self", ",", "var", ")", ":", "self", ".", "collection", ".", "variables", ".", "pop", "(", "var", ".", "name", ")", "return", "var", ".", "values" ]
Rename happens automatically in the base class, so all we need to do is unset the original variable in the collection.
[ "Rename", "happens", "automatically", "in", "the", "base", "class", "so", "all", "we", "need", "to", "do", "is", "unset", "the", "original", "variable", "in", "the", "collection", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/transformations/munge.py#L215-L219
17,687
bids-standard/pybids
bids/layout/writing.py
replace_entities
def replace_entities(entities, pattern): """ Replaces all entity names in a given pattern with the corresponding values provided by entities. Args: entities (dict): A dictionary mapping entity names to entity values. pattern (str): A path pattern that contains entity names denoted ...
python
def replace_entities(entities, pattern): """ Replaces all entity names in a given pattern with the corresponding values provided by entities. Args: entities (dict): A dictionary mapping entity names to entity values. pattern (str): A path pattern that contains entity names denoted ...
[ "def", "replace_entities", "(", "entities", ",", "pattern", ")", ":", "ents", "=", "re", ".", "findall", "(", "r'\\{(.*?)\\}'", ",", "pattern", ")", "new_path", "=", "pattern", "for", "ent", "in", "ents", ":", "match", "=", "re", ".", "search", "(", "r...
Replaces all entity names in a given pattern with the corresponding values provided by entities. Args: entities (dict): A dictionary mapping entity names to entity values. pattern (str): A path pattern that contains entity names denoted by curly braces. Optional portions denoted by ...
[ "Replaces", "all", "entity", "names", "in", "a", "given", "pattern", "with", "the", "corresponding", "values", "provided", "by", "entities", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/writing.py#L16-L55
17,688
bids-standard/pybids
bids/layout/writing.py
write_contents_to_file
def write_contents_to_file(path, contents=None, link_to=None, content_mode='text', root=None, conflicts='fail'): """ Uses provided filename patterns to write contents to a new path, given a corresponding entity map. Args: path (str): Destination path of the desired co...
python
def write_contents_to_file(path, contents=None, link_to=None, content_mode='text', root=None, conflicts='fail'): """ Uses provided filename patterns to write contents to a new path, given a corresponding entity map. Args: path (str): Destination path of the desired co...
[ "def", "write_contents_to_file", "(", "path", ",", "contents", "=", "None", ",", "link_to", "=", "None", ",", "content_mode", "=", "'text'", ",", "root", "=", "None", ",", "conflicts", "=", "'fail'", ")", ":", "if", "root", "is", "None", "and", "not", ...
Uses provided filename patterns to write contents to a new path, given a corresponding entity map. Args: path (str): Destination path of the desired contents. contents (str): Raw text or binary encoded string of contents to write to the new path. link_to (str): Optional path...
[ "Uses", "provided", "filename", "patterns", "to", "write", "contents", "to", "a", "new", "path", "given", "a", "corresponding", "entity", "map", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/layout/writing.py#L109-L177
17,689
bids-standard/pybids
bids/reports/report.py
BIDSReport.generate
def generate(self, **kwargs): """Generate the methods section. Parameters ---------- task_converter : :obj:`dict`, optional A dictionary with information for converting task names from BIDS filename format to human-readable strings. Returns -----...
python
def generate(self, **kwargs): """Generate the methods section. Parameters ---------- task_converter : :obj:`dict`, optional A dictionary with information for converting task names from BIDS filename format to human-readable strings. Returns -----...
[ "def", "generate", "(", "self", ",", "*", "*", "kwargs", ")", ":", "descriptions", "=", "[", "]", "subjs", "=", "self", ".", "layout", ".", "get_subjects", "(", "*", "*", "kwargs", ")", "kwargs", "=", "{", "k", ":", "v", "for", "k", ",", "v", "...
Generate the methods section. Parameters ---------- task_converter : :obj:`dict`, optional A dictionary with information for converting task names from BIDS filename format to human-readable strings. Returns ------- counter : :obj:`collections.Co...
[ "Generate", "the", "methods", "section", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/report.py#L53-L92
17,690
bids-standard/pybids
bids/reports/report.py
BIDSReport._report_subject
def _report_subject(self, subject, **kwargs): """Write a report for a single subject. Parameters ---------- subject : :obj:`str` Subject ID. Attributes ---------- layout : :obj:`bids.layout.BIDSLayout` Layout object for a BIDS dataset. ...
python
def _report_subject(self, subject, **kwargs): """Write a report for a single subject. Parameters ---------- subject : :obj:`str` Subject ID. Attributes ---------- layout : :obj:`bids.layout.BIDSLayout` Layout object for a BIDS dataset. ...
[ "def", "_report_subject", "(", "self", ",", "subject", ",", "*", "*", "kwargs", ")", ":", "description_list", "=", "[", "]", "# Remove sess from kwargs if provided, else set sess as all available", "sessions", "=", "kwargs", ".", "pop", "(", "'session'", ",", "self"...
Write a report for a single subject. Parameters ---------- subject : :obj:`str` Subject ID. Attributes ---------- layout : :obj:`bids.layout.BIDSLayout` Layout object for a BIDS dataset. config : :obj:`dict` Configuration info...
[ "Write", "a", "report", "for", "a", "single", "subject", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/reports/report.py#L94-L147
17,691
bids-standard/pybids
bids/analysis/hrf.py
_gamma_difference_hrf
def _gamma_difference_hrf(tr, oversampling=50, time_length=32., onset=0., delay=6, undershoot=16., dispersion=1., u_dispersion=1., ratio=0.167): """ Compute an hrf as the difference of two gamma functions Parameters ---------- tr : float scan...
python
def _gamma_difference_hrf(tr, oversampling=50, time_length=32., onset=0., delay=6, undershoot=16., dispersion=1., u_dispersion=1., ratio=0.167): """ Compute an hrf as the difference of two gamma functions Parameters ---------- tr : float scan...
[ "def", "_gamma_difference_hrf", "(", "tr", ",", "oversampling", "=", "50", ",", "time_length", "=", "32.", ",", "onset", "=", "0.", ",", "delay", "=", "6", ",", "undershoot", "=", "16.", ",", "dispersion", "=", "1.", ",", "u_dispersion", "=", "1.", ","...
Compute an hrf as the difference of two gamma functions Parameters ---------- tr : float scan repeat time, in seconds oversampling : int, optional (default=16) temporal oversampling factor time_length : float, optional (default=32) hrf kernel length, in seconds onset...
[ "Compute", "an", "hrf", "as", "the", "difference", "of", "two", "gamma", "functions" ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L13-L61
17,692
bids-standard/pybids
bids/analysis/hrf.py
spm_hrf
def spm_hrf(tr, oversampling=50, time_length=32., onset=0.): """ Implementation of the SPM hrf model Parameters ---------- tr : float scan repeat time, in seconds oversampling : int, optional temporal oversampling factor time_length : float, optional hrf kernel length,...
python
def spm_hrf(tr, oversampling=50, time_length=32., onset=0.): """ Implementation of the SPM hrf model Parameters ---------- tr : float scan repeat time, in seconds oversampling : int, optional temporal oversampling factor time_length : float, optional hrf kernel length,...
[ "def", "spm_hrf", "(", "tr", ",", "oversampling", "=", "50", ",", "time_length", "=", "32.", ",", "onset", "=", "0.", ")", ":", "return", "_gamma_difference_hrf", "(", "tr", ",", "oversampling", ",", "time_length", ",", "onset", ")" ]
Implementation of the SPM hrf model Parameters ---------- tr : float scan repeat time, in seconds oversampling : int, optional temporal oversampling factor time_length : float, optional hrf kernel length, in seconds onset : float, optional hrf onset time, in s...
[ "Implementation", "of", "the", "SPM", "hrf", "model" ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L64-L86
17,693
bids-standard/pybids
bids/analysis/hrf.py
glover_hrf
def glover_hrf(tr, oversampling=50, time_length=32., onset=0.): """ Implementation of the Glover hrf model Parameters ---------- tr : float scan repeat time, in seconds oversampling : int, optional temporal oversampling factor time_length : float, optional hrf kernel l...
python
def glover_hrf(tr, oversampling=50, time_length=32., onset=0.): """ Implementation of the Glover hrf model Parameters ---------- tr : float scan repeat time, in seconds oversampling : int, optional temporal oversampling factor time_length : float, optional hrf kernel l...
[ "def", "glover_hrf", "(", "tr", ",", "oversampling", "=", "50", ",", "time_length", "=", "32.", ",", "onset", "=", "0.", ")", ":", "return", "_gamma_difference_hrf", "(", "tr", ",", "oversampling", ",", "time_length", ",", "onset", ",", "delay", "=", "6"...
Implementation of the Glover hrf model Parameters ---------- tr : float scan repeat time, in seconds oversampling : int, optional temporal oversampling factor time_length : float, optional hrf kernel length, in seconds onset : float, optional onset of the resp...
[ "Implementation", "of", "the", "Glover", "hrf", "model" ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L89-L113
17,694
bids-standard/pybids
bids/analysis/hrf.py
spm_dispersion_derivative
def spm_dispersion_derivative(tr, oversampling=50, time_length=32., onset=0.): """Implementation of the SPM dispersion derivative hrf model Parameters ---------- tr: float scan repeat time, in seconds oversampling: int, optional temporal oversampling factor in seconds time_len...
python
def spm_dispersion_derivative(tr, oversampling=50, time_length=32., onset=0.): """Implementation of the SPM dispersion derivative hrf model Parameters ---------- tr: float scan repeat time, in seconds oversampling: int, optional temporal oversampling factor in seconds time_len...
[ "def", "spm_dispersion_derivative", "(", "tr", ",", "oversampling", "=", "50", ",", "time_length", "=", "32.", ",", "onset", "=", "0.", ")", ":", "dd", "=", ".01", "dhrf", "=", "1.", "/", "dd", "*", "(", "-", "_gamma_difference_hrf", "(", "tr", ",", ...
Implementation of the SPM dispersion derivative hrf model Parameters ---------- tr: float scan repeat time, in seconds oversampling: int, optional temporal oversampling factor in seconds time_length: float, optional hrf kernel length, in seconds onset : float, optiona...
[ "Implementation", "of", "the", "SPM", "dispersion", "derivative", "hrf", "model" ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L169-L196
17,695
bids-standard/pybids
bids/analysis/hrf.py
glover_dispersion_derivative
def glover_dispersion_derivative(tr, oversampling=50, time_length=32., onset=0.): """Implementation of the Glover dispersion derivative hrf model Parameters ---------- tr: float scan repeat time, in seconds oversampling: int, optional temporal overs...
python
def glover_dispersion_derivative(tr, oversampling=50, time_length=32., onset=0.): """Implementation of the Glover dispersion derivative hrf model Parameters ---------- tr: float scan repeat time, in seconds oversampling: int, optional temporal overs...
[ "def", "glover_dispersion_derivative", "(", "tr", ",", "oversampling", "=", "50", ",", "time_length", "=", "32.", ",", "onset", "=", "0.", ")", ":", "dd", "=", ".01", "dhrf", "=", "1.", "/", "dd", "*", "(", "-", "_gamma_difference_hrf", "(", "tr", ",",...
Implementation of the Glover dispersion derivative hrf model Parameters ---------- tr: float scan repeat time, in seconds oversampling: int, optional temporal oversampling factor in seconds time_length: float, optional hrf kernel length, in seconds onset : float, opti...
[ "Implementation", "of", "the", "Glover", "dispersion", "derivative", "hrf", "model" ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L199-L230
17,696
bids-standard/pybids
bids/analysis/hrf.py
_sample_condition
def _sample_condition(exp_condition, frame_times, oversampling=50, min_onset=-24): """Make a possibly oversampled event regressor from condition information. Parameters ---------- exp_condition : arraylike of shape (3, n_events) yields description of events for this conditi...
python
def _sample_condition(exp_condition, frame_times, oversampling=50, min_onset=-24): """Make a possibly oversampled event regressor from condition information. Parameters ---------- exp_condition : arraylike of shape (3, n_events) yields description of events for this conditi...
[ "def", "_sample_condition", "(", "exp_condition", ",", "frame_times", ",", "oversampling", "=", "50", ",", "min_onset", "=", "-", "24", ")", ":", "# Find the high-resolution frame_times", "n", "=", "frame_times", ".", "size", "min_onset", "=", "float", "(", "min...
Make a possibly oversampled event regressor from condition information. Parameters ---------- exp_condition : arraylike of shape (3, n_events) yields description of events for this condition as a (onsets, durations, amplitudes) triplet frame_times : array of shape(n_scans) samp...
[ "Make", "a", "possibly", "oversampled", "event", "regressor", "from", "condition", "information", "." ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L233-L295
17,697
bids-standard/pybids
bids/analysis/hrf.py
_resample_regressor
def _resample_regressor(hr_regressor, hr_frame_times, frame_times): """ this function sub-samples the regressors at frame times Parameters ---------- hr_regressor : array of shape(n_samples), the regressor time course sampled at high temporal resolution hr_frame_times : array of shape(n_sa...
python
def _resample_regressor(hr_regressor, hr_frame_times, frame_times): """ this function sub-samples the regressors at frame times Parameters ---------- hr_regressor : array of shape(n_samples), the regressor time course sampled at high temporal resolution hr_frame_times : array of shape(n_sa...
[ "def", "_resample_regressor", "(", "hr_regressor", ",", "hr_frame_times", ",", "frame_times", ")", ":", "from", "scipy", ".", "interpolate", "import", "interp1d", "f", "=", "interp1d", "(", "hr_frame_times", ",", "hr_regressor", ")", "return", "f", "(", "frame_t...
this function sub-samples the regressors at frame times Parameters ---------- hr_regressor : array of shape(n_samples), the regressor time course sampled at high temporal resolution hr_frame_times : array of shape(n_samples), the corresponding time stamps frame_times: array of sha...
[ "this", "function", "sub", "-", "samples", "the", "regressors", "at", "frame", "times" ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L298-L319
17,698
bids-standard/pybids
bids/analysis/hrf.py
_orthogonalize
def _orthogonalize(X): """ Orthogonalize every column of design `X` w.r.t preceding columns Parameters ---------- X: array of shape(n, p) the data to be orthogonalized Returns ------- X: array of shape(n, p) the data after orthogonalization Notes ----- X is chang...
python
def _orthogonalize(X): """ Orthogonalize every column of design `X` w.r.t preceding columns Parameters ---------- X: array of shape(n, p) the data to be orthogonalized Returns ------- X: array of shape(n, p) the data after orthogonalization Notes ----- X is chang...
[ "def", "_orthogonalize", "(", "X", ")", ":", "if", "X", ".", "size", "==", "X", ".", "shape", "[", "0", "]", ":", "return", "X", "from", "scipy", ".", "linalg", "import", "pinv", ",", "norm", "for", "i", "in", "range", "(", "1", ",", "X", ".", ...
Orthogonalize every column of design `X` w.r.t preceding columns Parameters ---------- X: array of shape(n, p) the data to be orthogonalized Returns ------- X: array of shape(n, p) the data after orthogonalization Notes ----- X is changed in place. The columns are no...
[ "Orthogonalize", "every", "column", "of", "design", "X", "w", ".", "r", ".", "t", "preceding", "columns" ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L322-L345
17,699
bids-standard/pybids
bids/analysis/hrf.py
_regressor_names
def _regressor_names(con_name, hrf_model, fir_delays=None): """ Returns a list of regressor names, computed from con-name and hrf type Parameters ---------- con_name: string identifier of the condition hrf_model: string or None, hrf model chosen fir_delays: 1D array_like, optio...
python
def _regressor_names(con_name, hrf_model, fir_delays=None): """ Returns a list of regressor names, computed from con-name and hrf type Parameters ---------- con_name: string identifier of the condition hrf_model: string or None, hrf model chosen fir_delays: 1D array_like, optio...
[ "def", "_regressor_names", "(", "con_name", ",", "hrf_model", ",", "fir_delays", "=", "None", ")", ":", "if", "hrf_model", "in", "[", "'glover'", ",", "'spm'", ",", "None", "]", ":", "return", "[", "con_name", "]", "elif", "hrf_model", "in", "[", "\"glov...
Returns a list of regressor names, computed from con-name and hrf type Parameters ---------- con_name: string identifier of the condition hrf_model: string or None, hrf model chosen fir_delays: 1D array_like, optional, Delays used in case of an FIR model Returns --...
[ "Returns", "a", "list", "of", "regressor", "names", "computed", "from", "con", "-", "name", "and", "hrf", "type" ]
30d924ce770622bda0e390d613a8da42a2a20c32
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/analysis/hrf.py#L348-L375