Tools

To mitigate NFT permanence issues, NFTs can be pinned to IPFS using services such as Blockfrost. I made some functions that help create, pin, and unpin objects to IPFS via blockfrost. For example:

def create_ipfs(image):
    """ Upload to Blockfrost """
    with open(image, "rb") as file_upload:
        ipfs_create_url = "https://ipfs.blockfrost.io/api/v0/ipfs/add"
        headers = {"project_id": f"{config.BLOCKFROST_IPFS}"}
        files = {'file': file_upload}
        res = requests.post(ipfs_create_url,  files=files, headers=headers)
        res.raise_for_status()
        if res.status_code == 200:
            logging.info("Upload to Blockfrost OK")
            logging.info(res.json())
            return res.json()
        else:
            logger.error(" Upload to blockfrost FAIL")
            return False

Some python wrapper functions around the cardano-clito check e.g. wallet UTxOs:

>>> check_wallet_utxo(wallet)
['4a03c0d27287d70672046d0960ab8ea2c3f7cf7a6f06e46dba43c20d888d1435', '0', '4815699', 'lovelace', '+', '1', 'c470b5d803851809901fa2cc0f0f25cab2c6f2b359d88f6d404740d9.UWYO']

or communicate with blockchain to get current transaction details:

>>> get_tx_details(tx)
{'inputs': [{'address': 'addr_test1qrjm5yznqanvksa5mlm30ym0w8363u7v2h5alzlcxc66c85c0mclhxex5k3p9c0aaj5rhyjr9k9wv8fxnnqduh7zj3fs6m73l5', 'amount': [{'unit': 'lovelace', 'quantity': '5000000'}]}], 'outputs': [{'address': 'addr_test1qrmcvxtnsvf646rj6jmg2n5433az9s50ykez03pn6cksj7hg9s8d05cuf8wxww69u6avvs5psenqqcrq92zq7w68t4jscp4yxs', 'amount': [{'unit': 'lovelace', 'quantity': '4815699'}, {'unit': 'c470b5d803851809901fa2cc0f0f25cab2c6f2b359d88f6d404740d95557594f', 'quantity': '1'}]}]}

Simple functions to quickly inspect the an atomic design.

A set of tools to interface with the laser patterning system using python. These are contributed to the open-source project pymeasure.

A set of tools to interface with the vacuum pumps using python. These are contributed to the open-source project pymeasure.

The flip mirror was a crucial component to switch between reading and patterning LIG. The API for the flip mirror was not well documented and improvements were needed. Tool snippets using ftd2xx solved the issue:

if switch == 'on':
    motor = ftd2xx.openEx(serial)
    ...
    # Send raw bytes to USB driver.
    motor.write(b"\x6A\x04\x00\x01\x21\x01")  # up or 
    motor.close()
else:
    motor = ftd2xx.openEx(serial)
    ...
    motor.write(b"\x6A\x04\x00\x02\x21\x01")  # up or 
    motor.close()

Medical data are still often recorded by hand, which causes inaccurate reporting. A colleague from the local hospital presented to me a problem with extracting hand-written texts from irregular tables.This program aims to structure the extract texts from images that are typically jumbled when using Google OCR. In particular, we deal with texts from irregular table forms and store these electronically in a dataframe.

Although Google OCR output is often unstructured, we do get access to information about the entities and their positions in a JSON output file. I solved the problem by postprocess the data so that extracting whole lines of text or phrases using tokens.

def main(imagePath):
    # Generate the Optical Character Recognition (OCR) class
    ocr = Ocr()

    # Apply OCR on the image. Creates JSON with the text and the (x,y) coordinates of each word
    ocr.processFile(imagePath,'./data/output/')

    # Reads JSON and deletes it
    jsonFile = changeFileExtension(imagePath.split("/")[-1],"json")
    with open(jsonFile,'r') as f:
        image = json.load(f)

    # Extract tokens (Each word, its width, height and its coordinates)
    tokens = extractTokens(image)

    # Sort the tokens into lines
    lines = extractLines(tokens)

    # Put lines in a dataframe
    df = pd.DataFrame(lines)

    return df

Once the tokens are extracted, we store them in a dataframe and clean the data according to our specifications. Note, the data clean-up here is strictly case-by-case and works relatively well for our problem.

0

1

2

3

4

5

6

7

8

9

0

hursday

12/12/2019 12/12/2019

| Legend

Fully Booked

Admitted

Late Admission

Not Admitted

✓

Completed

In Progress

1

Last update:11/12/2019 14:22

User update:

MOHD ISYRAFUDDN BIN ISMAL

Task:

Changed Turn Number

Track Record(4)

None

None

None

None

2

MRN

Patient Information

Start

Procedure(s)

Duration

Surgeon(s)

Comments/Diagnosis

None

None

None

3

N342133

0900

1)-PERIODONTAL - REPOSITIONED FLAP (KOS

0230

DIAGNOSIS:

None

None

None

None

None

4

(4K) PEDIATRCS 3

MALE.MELAYU

RAWATAN DI BAWAH GENERAL ANAESTHESIA -

Q37.0: Cleft hard palate with bilateral cleft lip

None

None

None

None

None

None

5

OT: GOTS

MINOR).

Booked By:

None

None

None

None

None

None

None

Last updated