Over the years we have seen great improvements in medicine and technology. Medicine and technology have gone hand in hand over the years to improve healthcare. However, diagnosis has always been left to human experience. Given a prognosis we would perform a series of tests to come up with a diagnosis. What if we could automate the process of diagnosis through machine learning. This would help doctors focus on the core job rather than performing performing tests repeatedly. Machine learning would help us diagnose diseases faster and probably better. Our main aim is to create a system based on IoT and artificial intelligence to help diagnose diseases and also reveal new diseases if possible. This is not to replace doctors; it is to help them focus on other core problems of diagnosis. This system would help reduce efforts and costs to a great extent.
AimoftheProject
To show that the system we are proposing can be realised we plan on focussing on three prognosis heart, fertility diseases and diabetes. This is because we could only find data sets on these three. The dataset will be first analysed using pandas to draw a correlation between the attributes for better understanding of the dataset. We would then test various algorithms on the data set using Weka. After having selected the algorithm we would then implement it using TensorFlow to verify the same results. After the aforementioned tasks have been completed, we would build the cloud service and API for the model. Then we progress on to make the front end which would be made on the webOS platform. The API allows us to transfer data through various front-end systems. The presence of the API increases modularity and helps in debugging problems much easier.
Design and Implementation- Creating a web service with either LUNA API or DjangoRest Framework
- Creating a storage module
- UI for web browsable API
- Neural Networks Implementation
- Integrate Neural Networks
- Create User Interface with the help of Enact and React
- FETCH the API through GET and POST
- Go to http://webosose.org/discover/setting/requirements/
- Fulfil the requirements mentioned
- Then type
git clone https://github.com/webosose/build-webos.git
- Then
cd build-webos
- Then install the required tools by typing
sudo scripts/prerequisites.sh
- To configure build for Raspberry type pi
./mcf raspberrypi3
- Activate environment for build by typing
source oe-init-build-env
- Build the webos image by typing
bitbake webos-image
- The build may take about two hours
- For Rasberry Pi, the resulting image will be created at BUILD/deploy/images/raspberrypi3/webos-image-raspberrypi3.rootfs.rpi-sdimg
- Now you have to just flash the image on the sd card for the raspberry pi
For the front end we are going to use enact to develop our applications.
Firstly, we have to install node package manager. After having done so
We have to install enact using the command npm install -g @enact/cli.
Then type the command enact template install @enact/template-webostv
Then create the template for the application using enact create -t webostv Diagnostics_Front_End
Then cd src/App/App.js
Type the following code:
import {ActivityPanels} from '@enact/moonstone/Panels';import Changeable from '@enact/ui/Changeable';import kind from '@enact/core/kind';import MoonstoneDecorator from '@enact/moonstone/MoonstoneDecorator';import PropTypes from 'prop-types';import React from 'react';import Detail from './Detail.js';import List from './List.js';const kittens = [ 'Heart', 'Fertility', 'Diabetes',];const AppBase = kind({ name: 'App', propTypes: { index: PropTypes.number, kitten: PropTypes.number, onNavigate: PropTypes.func, onSelectKitten: PropTypes.func }, defaultProps: { index: 0, kitten: 0 }, handlers: { onSelectKitten: (ev, {onNavigate, onSelectKitten}) => { if (onSelectKitten) { onSelectKitten({ kitten: ev.index }); } // navigate to the detail panel on selection if (onNavigate) { onNavigate({ index: 1 }); } } }, render: ({index, kitten, onNavigate, onSelectKitten, ...rest}) => ( <ActivityPanels {...rest} index={index} onSelectBreadcrumb={onNavigate}> <List onSelectKitten={onSelectKitten}>{kittens}</List> <Detail name={kittens[kitten]} heart={kittens[kitten]==='Heart'?1:0} fertility={kittens[kitten]==='Fertility'?1:0} diabetes={kittens[kitten]==='Diabetes'?1:0}/> </ActivityPanels> )});const App = Changeable({prop: 'index', change: 'onNavigate'}, Changeable({prop: 'kitten', change: 'onSelectKitten'}, MoonstoneDecorator(AppBase) ));export default App;export {App, AppBase};
Create a Detail.js file and type the following code:
import {Header, Panel} from '@enact/moonstone/Panels';import React from 'react';import BodyText from '@enact/moonstone/BodyText';import Input from '@enact/moonstone/Input';import Layout from '@enact/ui/Layout';import {Cell} from '@enact/ui/Layout';import ExpandableList from '@enact/moonstone/ExpandableList';import EditableIntegerPicker from '@enact/moonstone/EditableIntegerPicker';import Button from '@enact/moonstone/Button';import axios from 'axios'class DetailBase extends React.Component{ constructor(props) { super(props); this.state = { 'age':0, 'sex':0, 'chest_pain_type':0, 'resting_blood_pressure_in_mm_HG':0, 'is_fasting_blood_sugar_greater_than_120_mg_dl':0, 'resting_electrocardiograph':0, 'exercise_induced':0, 'maximum_heart_rate_achieved':0, 'ST_depression_induced_by_exrecise_relative_to_rest':0, 'slope_Type':0, 'number_of_major_vessels_colored_by_fluoroscopy':0, 'thal':0, 'pregnancies':0, 'glucose':0, 'blood_pressure':0, 'skin_thickness':0, 'insulin':0, 'b_m_i':0, 'diabetes_pedigree_function':0, 'season':0, 'childish_diseases':0, 'accident_or_serious_trauma':0, 'surgical_intervention':0, 'high_fevers_in_last_year':0, 'frequency_of_alcohol_consumption':0, 'smoking_habit':0, 'no_of_hours_spent_sitting_per_day':0, 'heartresult':0, 'diabtesresult':0, 'fertilityresult':0, } this.handleChangeofage=this.handleChangeofage.bind(this) this.handleChangeofsex=this.handleChangeofsex.bind(this) this.handleChangeofchestpain=this.handleChangeofchestpain.bind(this) this.handleChangeofrbp=this.handleChangeofrbp.bind(this) this.handleChangeofserumcholestrol=this.handleChangeofserumcholestrol.bind(this) this.handlefastingbloodsugar=this.handlefastingbloodsugar.bind(this) this.handleChangeofrcg=this.handleChangeofrcg.bind(this) this.handleMaxheartrate=this.handleMaxheartrate.bind(this) this.handleExerciseInduced=this.handleExerciseInduced.bind(this) this.handleSTdepression=this.handleSTdepression.bind(this) this.handleChangeofslopetype=this.handleChangeofslopetype.bind(this) this.handleNoofcellscoloredbyfluoroscopy=this.handleNoofcellscoloredbyfluoroscopy.bind(this) this.handleChangeofthaltype=this.handleChangeofthaltype.bind(this) this.handleChangepregnancy=this.handleChangepregnancy.bind(this) this.handleChangeofglucose=this.handleChangeofglucose.bind(this) this.handleChangeofbp=this.handleChangeofbp.bind(this) this.handleChangeofskin=this.handleChangeofskin.bind(this) this.handleChangeInsulin=this.handleChangeInsulin.bind(this) this.handleChangeofbmi=this.handleChangeofbmi.bind(this) this.handlechangeofdiabetespedigress=this.handlechangeofdiabetespedigress.bind(this) this.handleChangeSeason=this.handleChangeSeason.bind(this) this.handleChangeChildishDiseases=this.handleChangeChildishDiseases.bind(this) this.handleaccident=this.handleaccident.bind(this) this.handlesurgicalintervention=this.handlesurgicalintervention.bind(this) this.handlehighfeversinlastyear=this.handlehighfeversinlastyear.bind(this) this.handlefrequencyofalcoholconsumtion=this.handlefrequencyofalcoholconsumtion.bind(this) this.handlesmokinghabit=this.handlesmokinghabit.bind(this) this.handlenoofhoursspent=this.handlenoofhoursspent.bind(this) this.onClick=this.onClick.bind(this) this.sendDiabetes=this.sendDiabetes.bind(this) this.sendFertility=this.sendFertility.bind(this) } handleChangeSeason(ev) { this.setState( { 'season':ev.selected, } ) } handleChangeChildishDiseases(ev) { this.setState( { 'childish_diseases':ev.selected, } ) } handleaccident(ev) { this.setState( { 'accident_or_serious_trauma':ev.selected, } ) } handlesurgicalintervention(ev) { this.setState( { 'surgical_intervention':ev.selected, } ) } handlehighfeversinlastyear(ev) { this.setState( { 'high_fevers_in_last_year':ev.selected } ) } handlefrequencyofalcoholconsumtion(ev) { this.setState( { 'frequency_of_alcohol_consumption':ev.selected } ) } handlesmokinghabit(ev) { this.setState( { 'smoking_habit':ev.selected } ) } handlenoofhoursspent(ev) { this.setState( { 'no_of_hours_spent_sitting_per_day':ev.value, } ) } handleChangeofage(ev) { this.setState( { 'age':ev.value, } ) } handleChangeofsex(ev) { this.setState( { 'sex':ev.selected, } ) } handleChangeofchestpain(ev) { this.setState( { 'chest_pain_type':ev.selected, } ) } handleChangeofrbp(ev) { this.setState( { 'resting_blood_pressure_in_mm_HG':ev.value, } ) } handleChangeofserumcholestrol(ev) { this.setState( { 'serum_cholestrol_in_mg_dl':ev.value, } ) } handlefastingbloodsugar(ev) { this.setState( { 'is_fasting_blood_sugar_greater_than_120_mg_dl':ev.selected, } ) } handleChangeofrcg(ev) { this.setState( { 'resting_electrocardiograph':ev.selected, } ) } handleMaxheartrate(ev) { this.setState( { 'maximum_heart_rate_achieved':ev.value, } ) } handleExerciseInduced(ev) { this.setState( { 'exercise_induced':ev.selected, } ) } handleSTdepression(ev) { let a=Number(ev.value) this.setState( { 'ST_depression_induced_by_exrecise_relative_to_rest':a, } ) } handleChangeofslopetype(ev) { this.setState( { 'slope_Type':ev.selected, } ) } handleNoofcellscoloredbyfluoroscopy(ev) { this.setState( { 'number_of_major_vessels_colored_by_fluoroscopy':ev.value, } ) } handleChangeofthaltype(ev) { this.setState( { 'thal':ev.selected, } ) } async onClick(np) { console.log(this.state) console.log('/') console.log(this.state) let params={ "id": 0, "age": this.state.age, "sex": this.state.sex, "chest_pain_type": this.state.chest_pain_type, "resting_blood_pressure_in_mm_HG": this.state.resting_blood_pressure_in_mm_HG, "serum_cholestrol_in_mg_dl": this.state.serum_cholestrol_in_mg_dl, "is_fasting_blood_sugar_greater_than_120_mg_dl": this.state.is_fasting_blood_sugar_greater_than_120_mg_dl, "resting_electrocardiograph": this.state.resting_electrocardiograph, "maximum_heart_rate_achieved": this.state.maximum_heart_rate_achieved, "exercise_induced": this.state.exercise_induced, "ST_depression_induced_by_exrecise_relative_to_rest": this.state.ST_depression_induced_by_exrecise_relative_to_rest, "slope_Type": this.state.slope_Type, "number_of_major_vessels_colored_by_fluoroscopy": this.state.number_of_major_vessels_colored_by_fluoroscopy, "thal": this.state.thal, "target": 0 } console.log(params) console.log('Data prepared') console.log('Data posting') const promise=await axios.post('http://192.168.43.130/heart/HeartAPI/',params) console.log("Data posted") console.log(promise.status) const targetresult=await axios.get('http://192.168.43.130/heart/HeartAPI/') this.setState( { 'heartresult':targetresult.data[0]['target'] } ) console.log() } handleChangepregnancy(ev) { this.setState( { 'pregnancies':ev.value, } ) } handleChangeofglucose(ev) { this.setState( { 'glucose':ev.value, } ) } handleChangeofbp(ev) { this.setState( { 'blood_pressure':ev.value, } ) } handleChangeofskin(ev) { this.setState( { 'skin_thickness':ev.value, } ) } handleChangeInsulin(ev) { this.setState( { 'insulin':ev.value, } ) } handleChangeofbmi(ev) { this.setState( { 'b_m_i':ev.value, } ) } handlechangeofdiabetespedigress(ev) { this.setState( { 'diabetes_pedigree_function':ev.value, } ) } async sendDiabetes() { console.log(this.state) console.log(this.state) let diabetes_params={ "id": 1, "pregnancies": this.state.pregnancies, "glucose": this.state.glucose, "blood_pressure": this.state.blood_pressure, "skin_thickness": this.state.skin_thickness, "insulin": this.state.insulin, "b_m_i": this.state.b_m_i, "diabetes_pedigree_function":this.state.diabetes_pedigree_function, "age": this.state.age, "outcome": 0 } console.log("Data prepared") console.log("Posting....") const postResult=await axios.post('http://192.168.43.130/diabetes/DiabetesAPI/',diabetes_params) console.log("Posted") console.log(postResult.status) const receivediabetes=await axios.get('http://192.168.43.130/diabetes/DiabetesAPI/') console.log(receivediabetes.data[0]["outcome"]) this.setState( { 'diabtesresult':receivediabetes.data[0]['outcome'] } ) } async sendFertility() { let fertility_params={ "id": 1, "season": this.state.season, "age": this.state.age, "childish_diseases": this.state.childish_diseases, "accident_or_serious_trauma": this.state.accident_or_serious_trauma, "surgical_intervention": this.state.surgical_intervention, "high_fevers_in_last_year": this.state.high_fevers_in_last_year, "frequency_of_alcohol_consumption": this.state.frequency_of_alcohol_consumption, "smoking_habit": this.state.smoking_habit, "no_of_hours_spent_sitting_per_day": this.state.no_of_hours_spent_sitting_per_day, "confidence": 0.0 } console.log("Data Prepared") console.log("Posting") const sent=await axios.post('http://192.168.43.130/fertility/FertilityAPI/',fertility_params) console.log("Posted") console.log(sent.status) const receive=await axios.get('http://192.168.43.130/fertility/FertilityAPI/') this.setState( { 'fertilityresult':receive.data[0]['confidence'] } ) } render() { return ( <Panel> <Header title={this.props.name}/> {this.props.heart===1 ?<div><Layout> <Cell shrink>AGE:<EditableIntegerPicker onChange={this.handleChangeofage} min={0} max={200} value={this.state.age}/></Cell> <Cell shrink><ExpandableList noneText="None" title='Sex' name="sex" onSelect={this.handleChangeofsex} closeOnSelect={true} select='radio'> {['FEMALE','MALE']}</ExpandableList></Cell><Cell shrink><ExpandableList noneText="None" title="Chest pain Type" name='chest_pain_type' closeOnSelect={true} select='radio' onSelect={this.handleChangeofchestpain}> {['Type 0', 'Type 1','Type 2', 'Type 3']}</ExpandableList></Cell><Cell shrink>Resting Blood Pressure:<EditableIntegerPicker editMode={false} min={0} max={500} value={this.state.resting_blood_pressure_in_mm_HG} onChange={this.handleChangeofrbp} name='resting_blood_pressure_in_mm_HG'/></Cell></Layout><Layout><Cell shrink>Cholestrol:<EditableIntegerPicker editMode={false} onChange={this.handleChangeofserumcholestrol} min={0} max={500} name='serum_cholestrol_in_mg_dl'/></Cell><Cell shrink><ExpandableList closeOnSelect={true} select='radio' onSelect={this.handlefastingbloodsugar} name="is_fasting_blood_sugar_greater_than_120_mg_dl" noneText="None" title="Fasting Blood Sugar">{["Less than 120 mg/dl","Greater than 120 mg/dl"]}</ExpandableList></Cell><Cell shrink><ExpandableList noneText="None" closeOnSelect={true} select='radio' onSelect={this.handleChangeofrcg} title="Resting ElectroCardioGraph">{["Type 0","Type 1","Type 2"]}</ExpandableList></Cell></Layout><Layout><Cell shrink>Maximum Heart Rate Achieved:<EditableIntegerPicker editMode={false}onChange={this.handleMaxheartrate} min={0} max={500}/></Cell><Cell shrink><ExpandableList noneText="None" closeOnSelect={true} select='radio' onSelect={this.handleExerciseInduced} title="Exercise induced">{["Yes","No"]}</ExpandableList></Cell><Cell shrink><Input onChange={this.handleSTdepression} placeholder="ST depression induced by exrecise relative to rest"></Input></Cell></Layout><Layout><Cell shrink><ExpandableList onSelect={this.handleChangeofslopetype} closeOnSelect={true} select='radio' noneText="None" title="Slope Type">{["Type 0","Type 1","Type 2"]}</ExpandableList></Cell><Cell shrink>No. of cells colored by fluoroscopy:<EditableIntegerPicker onChange={this.handleNoofcellscoloredbyfluoroscopy} min={0} max={10}/></Cell><Cell shrink><ExpandableList closeOnSelect={true} select='radio' onSelect={this.handleChangeofthaltype} noneText='None' title='Thal type'>{['Not Found','Normal','Fixed Defect','Reversable Defect']}</ExpandableList></Cell></Layout><BodyText centered><Layout> <Cell> <Button onClick={this.onClick}>Submit</Button> </Cell></Layout></BodyText><BodyText centered> <Layout> <Cell> Confidence:{this.state.heartresult}% </Cell> </Layout> <Layout> <Cell> Chances:{this.state.heartresult<50?"Low chances of heart attack":this.state.heartresult>=50&&this.state.heartresult<80?"May or May not be a heart attack":this.state.heartresult>=80&&this.state.heartresult<=100?"High chances of heart attack":"Cannot Say"} </Cell> </Layout></BodyText></div> : this.props.diabetes===1 ? <div> <Layout> <Cell shrink> Pregnancies:<EditableIntegerPicker editMode={false}onChange={this.handleChangepregnancy} min={0} max={100}/> </Cell> <Cell shrink> Glucose:<EditableIntegerPicker editMode={false} onChange={this.handleChangeofglucose} min={0} max={100}/> </Cell> <Cell shrink> Blood Pressure:<EditableIntegerPicker editMode={false} onChange={this.handleChangeofbp} min={0} max={500}/> </Cell> </Layout> <Layout> <Cell shrink> Skin thickness:<EditableIntegerPicker editMode={false} onChange={this.handleChangeofskin} min={0} max={500}/> </Cell> <Cell shrink> Insulin:<EditableIntegerPicker editMode={false} onChange={this.handleChangeInsulin} min={0} max={500}/> </Cell> <Cell shrink> B.M.I.:<EditableIntegerPicker editMode={false} onChange={this.handleChangeofbmi} min={0} max={500}/> </Cell> </Layout> <Layout> <Cell shrink> Diabetes Pedigree Function:<EditableIntegerPicker editMode={false} onChange={this.handlechangeofdiabetespedigress} min={0} max={500}/> </Cell> <Cell shrink> Age:<EditableIntegerPicker editMode={false} onChange={this.handleChangeofage} min={0} max={500}/> </Cell> </Layout> <BodyText centered><Button onClick={this.sendDiabetes}>Submit</Button> </BodyText> <BodyText centered> <Layout> <Cell> Confidence:{this.state.diabtesresult}% </Cell> </Layout> <Layout> <Cell> Chances:{this.state.diabtesresult<50?"Low chances of diabetes":this.state.diabtesresult>=50&&this.state.diabtesresult<80?"May or May not have diabetes":this.state.diabtesresult>=80&&this.state.heartresult<=100?"High chances of havin diabetes":"Cannot Say"} </Cell> </Layout></BodyText> </div> : this.props.fertility===1 ? <div> <Layout> <Cell shrink> <ExpandableList onSelect={this.handleChangeSeason} noneText="None" title="Season" closeOnSelect={true} select='radio'>{["None","Spring","Fall","Winter","Summer"]}</ExpandableList> </Cell> <Cell shrink> Age:<EditableIntegerPicker editMode={false} onChange={this.handleChangeofage} min={0} max={200}/> </Cell> <Cell shrink> <ExpandableList onSelect={this.handleChangeChildishDiseases} title="Childish Diseases" noneText="None" closeOnSelect={true} select='radio'>{['No','Yes']}</ExpandableList> </Cell> <Cell shrink> <ExpandableList onSelect={this.handleaccident} title="Accident or Trauma" noneText="None" closeOnSelect={true} select='radio'>{['No','Yes']}</ExpandableList> </Cell> <Cell shrink> <ExpandableList onSelect={this.handlesurgicalintervention} title="Surgical Intervention" noneText="None" closeOnSelect={true} select='radio'>{['No','Yes']}</ExpandableList> </Cell> </Layout> <Layout> <Cell shrink> <ExpandableList onSelect={this.handlehighfeversinlastyear} title="High fevers in last year" noneText="None" closeOnSelect={true} select='radio'>{['None','More Than 3 months ago','Less Than 3 months Ago','No']}</ExpandableList> </Cell> <Cell shrink> <ExpandableList onSelect={this.handlefrequencyofalcoholconsumtion} title="Frequency of Alcohol consumption" noneText="None" closeOnSelect={true} select='radio'>{['None','once a week','hardly ever or never','several times a week','several times a day','every day']}</ExpandableList> </Cell> <Cell shrink> <ExpandableList onSelect={this.handlesmokinghabit} title="Smoking habbit" noneText="None" closeOnSelect={true} select='radio'>{['None','occasional','daily','never']}</ExpandableList> </Cell> </Layout> <Layout> <Cell shrink> No. hours spent sitting:<EditableIntegerPicker editMode={false} onChange={this.handlenoofhoursspent} min={0} max={500}/> </Cell> </Layout> <BodyText centered> <Button onClick={this.sendFertility}>Submit</Button> </BodyText> <BodyText centered> <Layout> <Cell> Confidence:{this.state.fertilityresult}% </Cell> </Layout> <Layout> <Cell> Chances:{this.state.fertilityresult<50?"Low chances of infertility":this.state.fertilityresult>=50&&this.state.fertilityresult<80?"May or May not be infertile ":this.state.fertilityresult>=80&&this.state.fertilityresult<=100?"High chances of infertility":"Cannot Say"} </Cell> </Layout></BodyText> </div>:"Nothing" } </Panel> ); }}export default DetailBase;export {DetailBase as Detail, DetailBase};
You can view the interface by running npm run serve
Screen shots of the user interface:
Backend code clone from https://github.com/Alton1998/Diagnostics
Comments
Please log in or sign up to comment.